<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE BangPatterns, CPP, GeneralizedNewtypeDeriving, MagicHash,
    UnliftedFFITypes #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE Trustworthy #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE TypeApplications #-}</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Module      : Data.Text.Encoding</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Copyright   : (c) 2009, 2010, 2011 Bryan O'Sullivan,</span><span>
</span><span id="line-8"></span><span class="hs-comment">--               (c) 2009 Duncan Coutts,</span><span>
</span><span id="line-9"></span><span class="hs-comment">--               (c) 2008, 2009 Tom Harper</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Portability : portable</span><span>
</span><span id="line-14"></span><span class="hs-comment">--</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Functions for converting 'Text' values to and from 'ByteString',</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- using several standard encodings.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- To gain access to a much larger family of encodings, use the</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- &lt;http://hackage.haskell.org/package/text-icu text-icu package&gt;.</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Encoding</span><span>
</span><span id="line-22"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-23"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Decoding ByteStrings to Text</span></span><span>
</span><span id="line-24"></span><span>    </span><span class="annot"><span class="hs-comment">-- $strict</span></span><span>
</span><span id="line-25"></span><span>      </span><span class="annot"><a href="Data.Text.Encoding.html#decodeASCII"><span class="hs-identifier">decodeASCII</span></a></span><span>
</span><span id="line-26"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeLatin1"><span class="hs-identifier">decodeLatin1</span></a></span><span>
</span><span id="line-27"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-identifier">decodeUtf8</span></a></span><span>
</span><span id="line-28"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LE"><span class="hs-identifier">decodeUtf16LE</span></a></span><span>
</span><span id="line-29"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BE"><span class="hs-identifier">decodeUtf16BE</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LE"><span class="hs-identifier">decodeUtf32LE</span></a></span><span>
</span><span id="line-31"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BE"><span class="hs-identifier">decodeUtf32BE</span></a></span><span>
</span><span id="line-32"></span><span>
</span><span id="line-33"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Catchable failure</span></span><span>
</span><span id="line-34"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8%27"><span class="hs-identifier">decodeUtf8'</span></a></span><span>
</span><span id="line-35"></span><span>
</span><span id="line-36"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Controllable error handling</span></span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8With"><span class="hs-identifier">decodeUtf8With</span></a></span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LEWith"><span class="hs-identifier">decodeUtf16LEWith</span></a></span><span>
</span><span id="line-39"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BEWith"><span class="hs-identifier">decodeUtf16BEWith</span></a></span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LEWith"><span class="hs-identifier">decodeUtf32LEWith</span></a></span><span>
</span><span id="line-41"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BEWith"><span class="hs-identifier">decodeUtf32BEWith</span></a></span><span>
</span><span id="line-42"></span><span>
</span><span id="line-43"></span><span>    </span><span class="annot"><span class="hs-comment">-- ** Stream oriented decoding</span></span><span>
</span><span id="line-44"></span><span>    </span><span class="annot"><span class="hs-comment">-- $stream</span></span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#streamDecodeUtf8"><span class="hs-identifier">streamDecodeUtf8</span></a></span><span>
</span><span id="line-46"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#streamDecodeUtf8With"><span class="hs-identifier">streamDecodeUtf8With</span></a></span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier">Decoding</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Encoding Text to ByteStrings</span></span><span>
</span><span id="line-50"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8"><span class="hs-identifier">encodeUtf8</span></a></span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16LE"><span class="hs-identifier">encodeUtf16LE</span></a></span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16BE"><span class="hs-identifier">encodeUtf16BE</span></a></span><span>
</span><span id="line-53"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32LE"><span class="hs-identifier">encodeUtf32LE</span></a></span><span>
</span><span id="line-54"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32BE"><span class="hs-identifier">encodeUtf32BE</span></a></span><span>
</span><span id="line-55"></span><span>
</span><span id="line-56"></span><span>    </span><span class="annot"><span class="hs-comment">-- * Encoding Text using ByteString Builders</span></span><span>
</span><span id="line-57"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8Builder"><span class="hs-identifier">encodeUtf8Builder</span></a></span><span>
</span><span id="line-58"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8BuilderEscaped"><span class="hs-identifier">encodeUtf8BuilderEscaped</span></a></span><span>
</span><span id="line-59"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-60"></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.Unsafe.html#"><span class="hs-identifier">Control.Monad.ST.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#unsafeIOToST"><span class="hs-identifier">unsafeIOToST</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#unsafeSTToIO"><span class="hs-identifier">unsafeSTToIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-62"></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier">evaluate</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier">try</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier">throwIO</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exception.html#ErrorCall"><span class="hs-identifier">ErrorCall</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exception.html#ErrorCall"><span class="hs-identifier">ErrorCall</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.ST.html#"><span class="hs-identifier">Control.Monad.ST</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier">runST</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Bits.html#"><span class="hs-identifier">Data.Bits</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator">(.&amp;.)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.html#"><span class="hs-identifier">Data.ByteString</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">B</span></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#"><span class="hs-identifier">Data.ByteString.Internal</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">B</span></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#"><span class="hs-identifier">Data.Foldable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#traverse_"><span class="hs-identifier">traverse_</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html"><span class="hs-identifier">Data.Text.Encoding.Error</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier">OnDecodeError</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier">UnicodeException</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier">strictDecode</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.html"><span class="hs-identifier">Data.Text.Internal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier">Text</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#safe"><span class="hs-keyword">safe</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#text"><span class="hs-identifier">text</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Functions.html"><span class="hs-identifier">Data.Text.Internal.Functions</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Private.html"><span class="hs-identifier">Data.Text.Internal.Private</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Private.html#runText"><span class="hs-identifier">runText</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Char.html"><span class="hs-identifier">Data.Text.Internal.Unsafe.Char</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Unsafe.Char.html#ord"><span class="hs-identifier">ord</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Char.html#unsafeWrite"><span class="hs-identifier">unsafeWrite</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html"><span class="hs-identifier">Data.Text.Internal.Unsafe.Shift</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-identifier">shiftR</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Show.html"><span class="hs-identifier">Data.Text.Show</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Unsafe.html"><span class="hs-identifier">Data.Text.Unsafe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier">unsafeDupablePerformIO</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier">Word16</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier">Word32</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#"><span class="hs-identifier">Foreign.C.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier">CSize</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier">CSize</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Marshal.Utils.html#"><span class="hs-identifier">Foreign.Marshal.Utils</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier">with</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Ptr.html#"><span class="hs-identifier">Foreign.Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#minusPtr"><span class="hs-identifier">minusPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier">nullPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier">plusPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Storable.html#"><span class="hs-identifier">Foreign.Storable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.Storable.html#Storable"><span class="hs-identifier">Storable</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier">peek</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier">poke</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#"><span class="hs-identifier">GHC.Base</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#ByteArray%23"><span class="hs-identifier">ByteArray#</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#MutableByteArray%23"><span class="hs-identifier">MutableByteArray#</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.html#"><span class="hs-identifier">Data.ByteString.Builder</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">B</span></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#"><span class="hs-identifier">Data.ByteString.Builder.Internal</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">B</span></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#empty"><span class="hs-identifier">empty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#append"><span class="hs-identifier">append</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Prim.html#"><span class="hs-identifier">Data.ByteString.Builder.Prim</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">BP</span></span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Internal.html#"><span class="hs-identifier">Data.ByteString.Builder.Prim.Internal</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">BP</span></span><span>
</span><span id="line-87"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Array.html"><span class="hs-identifier">Data.Text.Array</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">A</span></span><span>
</span><span id="line-88"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Fusion.html"><span class="hs-identifier">Data.Text.Internal.Encoding.Fusion</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">E</span></span><span>
</span><span id="line-89"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Utf16.html"><span class="hs-identifier">Data.Text.Internal.Encoding.Utf16</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">U16</span></span><span>
</span><span id="line-90"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.html"><span class="hs-identifier">Data.Text.Internal.Fusion</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">F</span></span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Text.Internal.ByteStringCompat.html"><span class="hs-identifier">Data.Text.Internal.ByteStringCompat</span></a></span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Stack</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">HasCallStack</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#include &quot;text_cbits.h&quot;
</span><span>
</span><span id="line-98"></span><span class="hs-comment">-- $strict</span><span>
</span><span id="line-99"></span><span class="hs-comment">--</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- All of the single-parameter functions for decoding bytestrings</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- encoded in one of the Unicode Transformation Formats (UTF) operate</span><span>
</span><span id="line-102"></span><span class="hs-comment">-- in a /strict/ mode: each will throw an exception if given invalid</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- input.</span><span>
</span><span id="line-104"></span><span class="hs-comment">--</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- Each function has a variant, whose name is suffixed with -'With',</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- that gives greater control over the handling of decoding errors.</span><span>
</span><span id="line-107"></span><span class="hs-comment">-- For instance, 'decodeUtf8' will throw an exception, but</span><span>
</span><span id="line-108"></span><span class="hs-comment">-- 'decodeUtf8With' allows the programmer to determine what to do on a</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- decoding error.</span><span>
</span><span id="line-110"></span><span>
</span><span id="line-111"></span><span class="hs-comment">-- | /Deprecated/.  Decode a 'ByteString' containing 7-bit ASCII</span><span>
</span><span id="line-112"></span><span class="hs-comment">-- encoded text.</span><span>
</span><span id="line-113"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeASCII"><span class="hs-identifier hs-type">decodeASCII</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-114"></span><span id="decodeASCII"><span class="annot"><span class="annottext">decodeASCII :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeASCII"><span class="hs-identifier hs-var hs-var">decodeASCII</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-identifier hs-var">decodeUtf8</span></a></span><span>
</span><span id="line-115"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">decodeASCII</span><span> </span><span class="hs-pragma">&quot;Use decodeUtf8 instead&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span class="hs-comment">-- | Decode a 'ByteString' containing Latin-1 (aka ISO-8859-1) encoded text.</span><span>
</span><span id="line-118"></span><span class="hs-comment">--</span><span>
</span><span id="line-119"></span><span class="hs-comment">-- 'decodeLatin1' is semantically equivalent to</span><span>
</span><span id="line-120"></span><span class="hs-comment">--  @Data.Text.pack . Data.ByteString.Char8.unpack@</span><span>
</span><span id="line-121"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeLatin1"><span class="hs-identifier hs-type">decodeLatin1</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-126"></span><span id="decodeLatin1"><span class="annot"><span class="annottext">decodeLatin1 :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeLatin1"><span class="hs-identifier hs-var hs-var">decodeLatin1</span></a></span></span><span> </span><span id="local-6989586621679109321"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109321"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; Text) -&gt; Text
forall r. ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; r) -&gt; r
</span><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier hs-var">withBS</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109321"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Text
</span><a href="#local-6989586621679109319"><span class="hs-identifier hs-var">aux</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-127"></span><span>  </span><span id="local-6989586621679109319"><span class="annot"><span class="annottext">aux :: ForeignPtr Word8 -&gt; Int -&gt; Text
</span><a href="#local-6989586621679109319"><span class="hs-identifier hs-var hs-var">aux</span></a></span></span><span> </span><span id="local-6989586621679109318"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109318"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679109317"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109317"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Int -&gt; Text
</span><a href="Data.Text.Internal.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679109316"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109317"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-128"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-129"></span><span>    </span><span id="local-6989586621679109316"><span class="annot"><span class="annottext">a :: Array
</span><a href="#local-6989586621679109316"><span class="hs-identifier hs-var hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s (MArray s)) -&gt; Array
</span><a href="Data.Text.Array.html#run"><span class="hs-identifier hs-var">A.run</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; ST s (MArray s)
forall s. Int -&gt; ST s (MArray s)
</span><a href="Data.Text.Array.html#new"><span class="hs-identifier hs-var">A.new</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109317"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">ST s (MArray s) -&gt; (MArray s -&gt; ST s (MArray s)) -&gt; ST s (MArray s)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">IO (MArray s) -&gt; ST s (MArray s)
forall a s. IO a -&gt; ST s a
</span><a href="../../base/src/GHC.IO.html#unsafeIOToST"><span class="hs-identifier hs-var">unsafeIOToST</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (MArray s) -&gt; ST s (MArray s))
-&gt; (MArray s -&gt; IO (MArray s)) -&gt; MArray s -&gt; ST s (MArray s)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s -&gt; IO (MArray s)
forall {s}. MArray s -&gt; IO (MArray s)
</span><a href="#local-6989586621679109310"><span class="hs-identifier hs-var">go</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-130"></span><span>    </span><span id="local-6989586621679109310"><span class="annot"><span class="annottext">go :: MArray s -&gt; IO (MArray s)
</span><a href="#local-6989586621679109310"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679109307"><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109307"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO (MArray s)) -&gt; IO (MArray s)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109318"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (MArray s)) -&gt; IO (MArray s))
-&gt; (Ptr Word8 -&gt; IO (MArray s)) -&gt; IO (MArray s)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109305"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109305"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-131"></span><span>      </span><span class="annot"><span class="annottext">MutableByteArray# s -&gt; Ptr Word8 -&gt; Ptr Word8 -&gt; IO ()
forall s. MutableByteArray# s -&gt; Ptr Word8 -&gt; Ptr Word8 -&gt; IO ()
</span><a href="Data.Text.Encoding.html#c_decode_latin1"><span class="hs-identifier hs-var">c_decode_latin1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MArray s -&gt; MutableByteArray# s
forall s. MArray s -&gt; MutableByteArray# s
</span><a href="Data.Text.Array.html#maBA"><span class="hs-identifier hs-var hs-var">A.maBA</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109307"><span class="hs-identifier hs-var">dest</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109305"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109305"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109317"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-132"></span><span>      </span><span class="annot"><span class="annottext">MArray s -&gt; IO (MArray s)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109307"><span class="hs-identifier hs-var">dest</span></a></span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-comment">-- | Decode a 'ByteString' containing UTF-8 encoded text.</span><span>
</span><span id="line-135"></span><span class="hs-comment">--</span><span>
</span><span id="line-136"></span><span class="hs-comment">-- __NOTE__: The replacement character returned by 'OnDecodeError'</span><span>
</span><span id="line-137"></span><span class="hs-comment">-- MUST be within the BMP plane; surrogate code points will</span><span>
</span><span id="line-138"></span><span class="hs-comment">-- automatically be remapped to the replacement char @U+FFFD@</span><span>
</span><span id="line-139"></span><span class="hs-comment">-- (/since 0.11.3.0/), whereas code points beyond the BMP will throw an</span><span>
</span><span id="line-140"></span><span class="hs-comment">-- 'error' (/since 1.2.3.1/); For earlier versions of @text@ using</span><span>
</span><span id="line-141"></span><span class="hs-comment">-- those unsupported code points would result in undefined behavior.</span><span>
</span><span id="line-142"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8With"><span class="hs-identifier hs-type">decodeUtf8With</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-147"></span><span id="decodeUtf8With"><span class="annot"><span class="annottext">decodeUtf8With :: OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf8With"><span class="hs-identifier hs-var hs-var">decodeUtf8With</span></a></span></span><span> </span><span id="local-6989586621679109302"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679109302"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span id="local-6989586621679109301"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109301"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; Text) -&gt; Text
forall r. ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; r) -&gt; r
</span><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier hs-var">withBS</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109301"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Text
</span><a href="#local-6989586621679109300"><span class="hs-identifier hs-var">aux</span></a></span><span>
</span><span id="line-148"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-149"></span><span>  </span><span id="local-6989586621679109300"><span class="annot"><span class="annottext">aux :: ForeignPtr Word8 -&gt; Int -&gt; Text
</span><a href="#local-6989586621679109300"><span class="hs-identifier hs-var hs-var">aux</span></a></span></span><span> </span><span id="local-6989586621679109299"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109299"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679109298"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109298"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text) -&gt; Text
</span><a href="Data.Text.Internal.Private.html#runText"><span class="hs-identifier hs-var">runText</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text) -&gt; Text)
-&gt; (forall s. (MArray s -&gt; Int -&gt; ST s Text) -&gt; ST s Text) -&gt; Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109296"><span class="annot"><span class="annottext">MArray s -&gt; Int -&gt; ST s Text
</span><a href="#local-6989586621679109296"><span class="hs-identifier hs-var">done</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-150"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679109292"><span class="annot"><span class="annottext">go :: MArray s -&gt; IO Text
</span><a href="#local-6989586621679109292"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679109291"><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109291"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Text) -&gt; IO Text
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109299"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Text) -&gt; IO Text)
-&gt; (Ptr Word8 -&gt; IO Text) -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109290"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109290"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-151"></span><span>          </span><span class="annot"><span class="annottext">CSize -&gt; (Ptr CSize -&gt; IO Text) -&gt; IO Text
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize
</span><span class="hs-number">0</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr CSize -&gt; IO Text) -&gt; IO Text)
-&gt; (Ptr CSize -&gt; IO Text) -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109289"><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109289"><span class="hs-identifier hs-var">destOffPtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-152"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679109288"><span class="annot"><span class="annottext">end :: Ptr b
</span><a href="#local-6989586621679109288"><span class="hs-identifier hs-var hs-var">end</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109290"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109298"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-153"></span><span>                </span><span id="local-6989586621679109271"><span class="annot"><span class="annottext">loop :: Ptr Word8 -&gt; IO Text
</span><a href="#local-6989586621679109271"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span id="local-6989586621679109270"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109270"><span class="hs-identifier hs-var">curPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-154"></span><span>                  </span><span id="local-6989586621679109269"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109269"><span class="hs-identifier hs-var">curPtr'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MutableByteArray# s
-&gt; Ptr CSize -&gt; Ptr Word8 -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
forall s.
MutableByteArray# s
-&gt; Ptr CSize -&gt; Ptr Word8 -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="Data.Text.Encoding.html#c_decode_utf8"><span class="hs-identifier hs-var">c_decode_utf8</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MArray s -&gt; MutableByteArray# s
forall s. MArray s -&gt; MutableByteArray# s
</span><a href="Data.Text.Array.html#maBA"><span class="hs-identifier hs-var hs-var">A.maBA</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109291"><span class="hs-identifier hs-var">dest</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109289"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109270"><span class="hs-identifier hs-var">curPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679109288"><span class="hs-identifier hs-var">end</span></a></span><span>
</span><span id="line-155"></span><span>                  </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109269"><span class="hs-identifier hs-var">curPtr'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679109288"><span class="hs-identifier hs-var">end</span></a></span><span>
</span><span id="line-156"></span><span>                    </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-157"></span><span>                      </span><span id="local-6989586621679109267"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679109267"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CSize -&gt; IO CSize
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109289"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span>
</span><span id="line-158"></span><span>                      </span><span class="annot"><span class="annottext">ST s Text -&gt; IO Text
forall s a. ST s a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#unsafeSTToIO"><span class="hs-identifier hs-var">unsafeSTToIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MArray s -&gt; Int -&gt; ST s Text
</span><a href="#local-6989586621679109296"><span class="hs-identifier hs-var">done</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109291"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
</span><a href="Data.Text.Encoding.html#cSizeToInt"><span class="hs-identifier hs-var">cSizeToInt</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679109267"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-159"></span><span>                    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-160"></span><span>                      </span><span id="local-6989586621679109265"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679109265"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Word8
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109269"><span class="hs-identifier hs-var">curPtr'</span></a></span><span>
</span><span id="line-161"></span><span>                      </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679109302"><span class="hs-identifier hs-var">onErr</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679109264"><span class="hs-identifier hs-var">desc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Maybe Word8
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679109265"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-162"></span><span>                        </span><span class="annot"><span class="annottext">Maybe Char
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Text
</span><a href="#local-6989586621679109271"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">(Ptr Word8 -&gt; IO Text) -&gt; Ptr Word8 -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109269"><span class="hs-identifier hs-var">curPtr'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-163"></span><span>                        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679109263"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679109263"><span class="hs-identifier hs-var">c</span></a></span></span><span>
</span><span id="line-164"></span><span>                          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679109263"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xFFFF'</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IO Text
forall {a}. IO a
</span><a href="#local-6989586621679109261"><span class="hs-identifier hs-var">throwUnsupportedReplChar</span></a></span><span>
</span><span id="line-165"></span><span>                          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-166"></span><span>                              </span><span id="local-6989586621679109260"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679109260"><span class="hs-identifier hs-var">destOff</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CSize -&gt; IO CSize
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109289"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span>
</span><span id="line-167"></span><span>                              </span><span id="local-6989586621679109259"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109259"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s Int -&gt; IO Int
forall s a. ST s a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#unsafeSTToIO"><span class="hs-identifier hs-var">unsafeSTToIO</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s Int -&gt; IO Int) -&gt; ST s Int -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-168"></span><span>                                   </span><span class="annot"><span class="annottext">MArray s -&gt; Int -&gt; Char -&gt; ST s Int
forall s. MArray s -&gt; Int -&gt; Char -&gt; ST s Int
</span><a href="Data.Text.Internal.Unsafe.Char.html#unsafeWrite"><span class="hs-identifier hs-var">unsafeWrite</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109291"><span class="hs-identifier hs-var">dest</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
</span><a href="Data.Text.Encoding.html#cSizeToInt"><span class="hs-identifier hs-var">cSizeToInt</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679109260"><span class="hs-identifier hs-var">destOff</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span>                                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Char
</span><a href="Data.Text.Internal.html#safe"><span class="hs-keyword hs-var">safe</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679109263"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span>                              </span><span class="annot"><span class="annottext">Ptr CSize -&gt; CSize -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109289"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679109260"><span class="hs-identifier hs-var">destOff</span></a></span><span> </span><span class="annot"><span class="annottext">CSize -&gt; CSize -&gt; CSize
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; CSize
</span><a href="Data.Text.Encoding.html#intToCSize"><span class="hs-identifier hs-var">intToCSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109259"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>                              </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Text
</span><a href="#local-6989586621679109271"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">(Ptr Word8 -&gt; IO Text) -&gt; Ptr Word8 -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109269"><span class="hs-identifier hs-var">curPtr'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-172"></span><span>            </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Text
</span><a href="#local-6989586621679109271"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109290"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-173"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO Text -&gt; ST s Text
forall a s. IO a -&gt; ST s a
</span><a href="../../base/src/GHC.IO.html#unsafeIOToST"><span class="hs-identifier hs-var">unsafeIOToST</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Text -&gt; ST s Text)
-&gt; (MArray s -&gt; IO Text) -&gt; MArray s -&gt; ST s Text
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s -&gt; IO Text
</span><a href="#local-6989586621679109292"><span class="hs-identifier hs-var">go</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(MArray s -&gt; ST s Text) -&gt; ST s (MArray s) -&gt; ST s Text
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s (MArray s)
forall s. Int -&gt; ST s (MArray s)
</span><a href="Data.Text.Array.html#new"><span class="hs-identifier hs-var">A.new</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109298"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-174"></span><span>   </span><span class="hs-keyword">where</span><span>
</span><span id="line-175"></span><span>    </span><span id="local-6989586621679109264"><span class="annot"><span class="annottext">desc :: String
</span><a href="#local-6989586621679109264"><span class="hs-identifier hs-var hs-var">desc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream&quot;</span></span><span>
</span><span id="line-176"></span><span>
</span><span id="line-177"></span><span>    </span><span id="local-6989586621679109261"><span class="annot"><span class="annottext">throwUnsupportedReplChar :: IO a
</span><a href="#local-6989586621679109261"><span class="hs-identifier hs-var hs-var">throwUnsupportedReplChar</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ErrorCall -&gt; IO a
forall e a. Exception e =&gt; e -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#throwIO"><span class="hs-identifier hs-var">throwIO</span></a></span><span> </span><span class="annot"><span class="annottext">(ErrorCall -&gt; IO a) -&gt; ErrorCall -&gt; IO a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-178"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; ErrorCall
</span><a href="../../base/src/GHC.Exception.html#ErrorCall"><span class="hs-identifier hs-var">ErrorCall</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;decodeUtf8With: non-BMP replacement characters not supported&quot;</span></span><span>
</span><span id="line-179"></span><span>  </span><span class="hs-comment">-- TODO: The code currently assumes that the transcoded UTF-16</span><span>
</span><span id="line-180"></span><span>  </span><span class="hs-comment">-- stream is at most twice as long (in bytes) as the input UTF-8</span><span>
</span><span id="line-181"></span><span>  </span><span class="hs-comment">-- stream. To justify this assumption one has to assume that the</span><span>
</span><span id="line-182"></span><span>  </span><span class="hs-comment">-- error handler replacement character also satisfies this</span><span>
</span><span id="line-183"></span><span>  </span><span class="hs-comment">-- invariant, by emitting at most one UTF16 code unit.</span><span>
</span><span id="line-184"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-comment">-- One easy way to support the full range of code-points for</span><span>
</span><span id="line-186"></span><span>  </span><span class="hs-comment">-- replacement characters in the error handler is to simply change</span><span>
</span><span id="line-187"></span><span>  </span><span class="hs-comment">-- the (over-)allocation to `A.new (2*len)` and then shrink back the</span><span>
</span><span id="line-188"></span><span>  </span><span class="hs-comment">-- `ByteArray#` to the real size (recent GHCs have a cheap</span><span>
</span><span id="line-189"></span><span>  </span><span class="hs-comment">-- `ByteArray#` resize-primop for that which allow the GC to reclaim</span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-comment">-- the overallocation). However, this would require 4 times as much</span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-comment">-- (temporary) storage as the original UTF-8 required.</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-193"></span><span>  </span><span class="hs-comment">-- Another strategy would be to optimistically assume that</span><span>
</span><span id="line-194"></span><span>  </span><span class="hs-comment">-- replacement characters are within the BMP, and if the case of a</span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-comment">-- non-BMP replacement occurs reallocate the target buffer (or throw</span><span>
</span><span id="line-196"></span><span>  </span><span class="hs-comment">-- an exception, and fallback to a pessimistic codepath, like e.g.</span><span>
</span><span id="line-197"></span><span>  </span><span class="hs-comment">-- `decodeUtf8With onErr bs = F.unstream (E.streamUtf8 onErr bs)`)</span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-199"></span><span>  </span><span class="hs-comment">-- Alternatively, `OnDecodeError` could become a datastructure which</span><span>
</span><span id="line-200"></span><span>  </span><span class="hs-comment">-- statically encodes the replacement-character range,</span><span>
</span><span id="line-201"></span><span>  </span><span class="hs-comment">-- e.g. something isomorphic to</span><span>
</span><span id="line-202"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-203"></span><span>  </span><span class="hs-comment">--   Either (... -&gt; Maybe Word16) (... -&gt; Maybe Char)</span><span>
</span><span id="line-204"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-comment">-- And allow to statically switch between the BMP/non-BMP</span><span>
</span><span id="line-206"></span><span>  </span><span class="hs-comment">-- replacement-character codepaths. There's multiple ways to address</span><span>
</span><span id="line-207"></span><span>  </span><span class="hs-comment">-- this with different tradeoffs; but ideally we should optimise for</span><span>
</span><span id="line-208"></span><span>  </span><span class="hs-comment">-- the optimistic/error-free case.</span><span>
</span><span id="line-209"></span><span class="hs-comment">{- INLINE[0] decodeUtf8With #-}</span><span>
</span><span id="line-210"></span><span>
</span><span id="line-211"></span><span class="hs-comment">-- $stream</span><span>
</span><span id="line-212"></span><span class="hs-comment">--</span><span>
</span><span id="line-213"></span><span class="hs-comment">-- The 'streamDecodeUtf8' and 'streamDecodeUtf8With' functions accept</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- a 'ByteString' that represents a possibly incomplete input (e.g. a</span><span>
</span><span id="line-215"></span><span class="hs-comment">-- packet from a network stream) that may not end on a UTF-8 boundary.</span><span>
</span><span id="line-216"></span><span class="hs-comment">--</span><span>
</span><span id="line-217"></span><span class="hs-comment">-- 1. The maximal prefix of 'Text' that could be decoded from the</span><span>
</span><span id="line-218"></span><span class="hs-comment">--    given input.</span><span>
</span><span id="line-219"></span><span class="hs-comment">--</span><span>
</span><span id="line-220"></span><span class="hs-comment">-- 2. The suffix of the 'ByteString' that could not be decoded due to</span><span>
</span><span id="line-221"></span><span class="hs-comment">--    insufficient input.</span><span>
</span><span id="line-222"></span><span class="hs-comment">--</span><span>
</span><span id="line-223"></span><span class="hs-comment">-- 3. A function that accepts another 'ByteString'.  That string will</span><span>
</span><span id="line-224"></span><span class="hs-comment">--    be assumed to directly follow the string that was passed as</span><span>
</span><span id="line-225"></span><span class="hs-comment">--    input to the original function, and it will in turn be decoded.</span><span>
</span><span id="line-226"></span><span class="hs-comment">--</span><span>
</span><span id="line-227"></span><span class="hs-comment">-- To help understand the use of these functions, consider the Unicode</span><span>
</span><span id="line-228"></span><span class="hs-comment">-- string @\&quot;hi &amp;#9731;\&quot;@. If encoded as UTF-8, this becomes @\&quot;hi</span><span>
</span><span id="line-229"></span><span class="hs-comment">-- \\xe2\\x98\\x83\&quot;@; the final @\'&amp;#9731;\'@ is encoded as 3 bytes.</span><span>
</span><span id="line-230"></span><span class="hs-comment">--</span><span>
</span><span id="line-231"></span><span class="hs-comment">-- Now suppose that we receive this encoded string as 3 packets that</span><span>
</span><span id="line-232"></span><span class="hs-comment">-- are split up on untidy boundaries: @[\&quot;hi \\xe2\&quot;, \&quot;\\x98\&quot;,</span><span>
</span><span id="line-233"></span><span class="hs-comment">-- \&quot;\\x83\&quot;]@. We cannot decode the entire Unicode string until we</span><span>
</span><span id="line-234"></span><span class="hs-comment">-- have received all three packets, but we would like to make progress</span><span>
</span><span id="line-235"></span><span class="hs-comment">-- as we receive each one.</span><span>
</span><span id="line-236"></span><span class="hs-comment">--</span><span>
</span><span id="line-237"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-238"></span><span class="hs-comment">-- ghci&gt; let s0\@('Some' _ _ f0) = 'streamDecodeUtf8' \&quot;hi \\xe2\&quot;</span><span>
</span><span id="line-239"></span><span class="hs-comment">-- ghci&gt; s0</span><span>
</span><span id="line-240"></span><span class="hs-comment">-- 'Some' \&quot;hi \&quot; \&quot;\\xe2\&quot; _</span><span>
</span><span id="line-241"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-242"></span><span class="hs-comment">--</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- We use the continuation @f0@ to decode our second packet.</span><span>
</span><span id="line-244"></span><span class="hs-comment">--</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-246"></span><span class="hs-comment">-- ghci&gt; let s1\@('Some' _ _ f1) = f0 \&quot;\\x98\&quot;</span><span>
</span><span id="line-247"></span><span class="hs-comment">-- ghci&gt; s1</span><span>
</span><span id="line-248"></span><span class="hs-comment">-- 'Some' \&quot;\&quot; \&quot;\\xe2\\x98\&quot;</span><span>
</span><span id="line-249"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-250"></span><span class="hs-comment">--</span><span>
</span><span id="line-251"></span><span class="hs-comment">-- We could not give @f0@ enough input to decode anything, so it</span><span>
</span><span id="line-252"></span><span class="hs-comment">-- returned an empty string. Once we feed our second continuation @f1@</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- the last byte of input, it will make progress.</span><span>
</span><span id="line-254"></span><span class="hs-comment">--</span><span>
</span><span id="line-255"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-256"></span><span class="hs-comment">-- ghci&gt; let s2\@('Some' _ _ f2) = f1 \&quot;\\x83\&quot;</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- ghci&gt; s2</span><span>
</span><span id="line-258"></span><span class="hs-comment">-- 'Some' \&quot;\\x2603\&quot; \&quot;\&quot; _</span><span>
</span><span id="line-259"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-260"></span><span class="hs-comment">--</span><span>
</span><span id="line-261"></span><span class="hs-comment">-- If given invalid input, an exception will be thrown by the function</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- or continuation where it is encountered.</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- | A stream oriented decoding result.</span><span>
</span><span id="line-265"></span><span class="hs-comment">--</span><span>
</span><span id="line-266"></span><span class="hs-comment">-- @since 1.0.0.0</span><span>
</span><span id="line-267"></span><span class="hs-keyword">data</span><span> </span><span id="Decoding"><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-var">Decoding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="Some"><span class="annot"><a href="Data.Text.Encoding.html#Some"><span class="hs-identifier hs-var">Some</span></a></span></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679109248"><span id="local-6989586621679109250"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-270"></span><span>    </span><span id="local-6989586621679109241"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; Decoding -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span id="local-6989586621679109239"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109239"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Encoding.html#Some"><span class="hs-identifier hs-type">Some</span></a></span><span> </span><span id="local-6989586621679109238"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679109238"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621679109237"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109237"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; Decoding
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; ShowS -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showParen"><span class="hs-identifier hs-var">showParen</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109239"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109235"><span class="hs-identifier hs-var">prec</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(ShowS -&gt; ShowS) -&gt; ShowS -&gt; ShowS
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-271"></span><span>                                </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Some &quot;</span></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Text -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109233"><span class="hs-identifier hs-var">prec'</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679109238"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-272"></span><span>                                </span><span class="annot"><span class="annottext">Char -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showChar"><span class="hs-identifier hs-var">showChar</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">' '</span></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109233"><span class="hs-identifier hs-var">prec'</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109237"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">ShowS -&gt; ShowS -&gt; ShowS
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span>
</span><span id="line-273"></span><span>                                </span><span class="annot"><span class="annottext">String -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showString"><span class="hs-identifier hs-var">showString</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot; _&quot;</span></span><span>
</span><span id="line-274"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679109235"><span class="annot"><span class="annottext">prec :: Int
</span><a href="#local-6989586621679109235"><span class="hs-identifier hs-var hs-var">prec</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">10</span></span><span class="hs-special">;</span><span> </span><span id="local-6989586621679109233"><span class="annot"><span class="annottext">prec' :: Int
</span><a href="#local-6989586621679109233"><span class="hs-identifier hs-var hs-var">prec'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109235"><span class="hs-identifier hs-var">prec</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span class="hs-keyword">newtype</span><span> </span><span id="CodePoint"><span class="annot"><a href="Data.Text.Encoding.html#CodePoint"><span class="hs-identifier hs-var">CodePoint</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="CodePoint"><span class="annot"><a href="Data.Text.Encoding.html#CodePoint"><span class="hs-identifier hs-var">CodePoint</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679109221"><span id="local-6989586621679109226"><span class="annot"><span class="annottext">CodePoint -&gt; CodePoint -&gt; Bool
(CodePoint -&gt; CodePoint -&gt; Bool)
-&gt; (CodePoint -&gt; CodePoint -&gt; Bool) -&gt; Eq CodePoint
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: CodePoint -&gt; CodePoint -&gt; Bool
$c/= :: CodePoint -&gt; CodePoint -&gt; Bool
== :: CodePoint -&gt; CodePoint -&gt; Bool
$c== :: CodePoint -&gt; CodePoint -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109208"><span id="local-6989586621679109210"><span id="local-6989586621679109215"><span class="annot"><span class="annottext">Int -&gt; CodePoint -&gt; ShowS
[CodePoint] -&gt; ShowS
CodePoint -&gt; String
(Int -&gt; CodePoint -&gt; ShowS)
-&gt; (CodePoint -&gt; String)
-&gt; ([CodePoint] -&gt; ShowS)
-&gt; Show CodePoint
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [CodePoint] -&gt; ShowS
$cshowList :: [CodePoint] -&gt; ShowS
show :: CodePoint -&gt; String
$cshow :: CodePoint -&gt; String
showsPrec :: Int -&gt; CodePoint -&gt; ShowS
$cshowsPrec :: Int -&gt; CodePoint -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109181"><span id="local-6989586621679109185"><span id="local-6989586621679109189"><span id="local-6989586621679109193"><span id="local-6989586621679109197"><span id="local-6989586621679109201"><span id="local-6989586621679109206"><span class="annot"><span class="annottext">Integer -&gt; CodePoint
CodePoint -&gt; CodePoint
CodePoint -&gt; CodePoint -&gt; CodePoint
(CodePoint -&gt; CodePoint -&gt; CodePoint)
-&gt; (CodePoint -&gt; CodePoint -&gt; CodePoint)
-&gt; (CodePoint -&gt; CodePoint -&gt; CodePoint)
-&gt; (CodePoint -&gt; CodePoint)
-&gt; (CodePoint -&gt; CodePoint)
-&gt; (CodePoint -&gt; CodePoint)
-&gt; (Integer -&gt; CodePoint)
-&gt; Num CodePoint
forall a.
(a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (Integer -&gt; a)
-&gt; Num a
fromInteger :: Integer -&gt; CodePoint
$cfromInteger :: Integer -&gt; CodePoint
signum :: CodePoint -&gt; CodePoint
$csignum :: CodePoint -&gt; CodePoint
abs :: CodePoint -&gt; CodePoint
$cabs :: CodePoint -&gt; CodePoint
negate :: CodePoint -&gt; CodePoint
$cnegate :: CodePoint -&gt; CodePoint
* :: CodePoint -&gt; CodePoint -&gt; CodePoint
$c* :: CodePoint -&gt; CodePoint -&gt; CodePoint
- :: CodePoint -&gt; CodePoint -&gt; CodePoint
$c- :: CodePoint -&gt; CodePoint -&gt; CodePoint
+ :: CodePoint -&gt; CodePoint -&gt; CodePoint
$c+ :: CodePoint -&gt; CodePoint -&gt; CodePoint
</span><a href="../../base/src/GHC.Num.html#Num"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Num</span></a></span></span></span></span></span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109147"><span id="local-6989586621679109151"><span id="local-6989586621679109155"><span id="local-6989586621679109159"><span id="local-6989586621679109163"><span id="local-6989586621679109167"><span id="local-6989586621679109171"><span id="local-6989586621679109176"><span class="annot"><span class="annottext">Ptr CodePoint -&gt; IO CodePoint
Ptr CodePoint -&gt; Int -&gt; IO CodePoint
Ptr CodePoint -&gt; Int -&gt; CodePoint -&gt; IO ()
Ptr CodePoint -&gt; CodePoint -&gt; IO ()
CodePoint -&gt; Int
(CodePoint -&gt; Int)
-&gt; (CodePoint -&gt; Int)
-&gt; (Ptr CodePoint -&gt; Int -&gt; IO CodePoint)
-&gt; (Ptr CodePoint -&gt; Int -&gt; CodePoint -&gt; IO ())
-&gt; (forall b. Ptr b -&gt; Int -&gt; IO CodePoint)
-&gt; (forall b. Ptr b -&gt; Int -&gt; CodePoint -&gt; IO ())
-&gt; (Ptr CodePoint -&gt; IO CodePoint)
-&gt; (Ptr CodePoint -&gt; CodePoint -&gt; IO ())
-&gt; Storable CodePoint
forall b. Ptr b -&gt; Int -&gt; IO CodePoint
forall b. Ptr b -&gt; Int -&gt; CodePoint -&gt; IO ()
forall a.
(a -&gt; Int)
-&gt; (a -&gt; Int)
-&gt; (Ptr a -&gt; Int -&gt; IO a)
-&gt; (Ptr a -&gt; Int -&gt; a -&gt; IO ())
-&gt; (forall b. Ptr b -&gt; Int -&gt; IO a)
-&gt; (forall b. Ptr b -&gt; Int -&gt; a -&gt; IO ())
-&gt; (Ptr a -&gt; IO a)
-&gt; (Ptr a -&gt; a -&gt; IO ())
-&gt; Storable a
poke :: Ptr CodePoint -&gt; CodePoint -&gt; IO ()
$cpoke :: Ptr CodePoint -&gt; CodePoint -&gt; IO ()
peek :: Ptr CodePoint -&gt; IO CodePoint
$cpeek :: Ptr CodePoint -&gt; IO CodePoint
pokeByteOff :: forall b. Ptr b -&gt; Int -&gt; CodePoint -&gt; IO ()
$cpokeByteOff :: forall b. Ptr b -&gt; Int -&gt; CodePoint -&gt; IO ()
peekByteOff :: forall b. Ptr b -&gt; Int -&gt; IO CodePoint
$cpeekByteOff :: forall b. Ptr b -&gt; Int -&gt; IO CodePoint
pokeElemOff :: Ptr CodePoint -&gt; Int -&gt; CodePoint -&gt; IO ()
$cpokeElemOff :: Ptr CodePoint -&gt; Int -&gt; CodePoint -&gt; IO ()
peekElemOff :: Ptr CodePoint -&gt; Int -&gt; IO CodePoint
$cpeekElemOff :: Ptr CodePoint -&gt; Int -&gt; IO CodePoint
alignment :: CodePoint -&gt; Int
$calignment :: CodePoint -&gt; Int
sizeOf :: CodePoint -&gt; Int
$csizeOf :: CodePoint -&gt; Int
</span><a href="../../base/src/Foreign.Storable.html#C%3AStorable"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Storable</span></a></span></span></span></span></span></span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-277"></span><span class="hs-keyword">newtype</span><span> </span><span id="DecoderState"><span class="annot"><a href="Data.Text.Encoding.html#DecoderState"><span class="hs-identifier hs-var">DecoderState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="DecoderState"><span class="annot"><a href="Data.Text.Encoding.html#DecoderState"><span class="hs-identifier hs-var">DecoderState</span></a></span></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word32"><span class="hs-identifier hs-type">Word32</span></a></span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679109136"><span id="local-6989586621679109140"><span class="annot"><span class="annottext">DecoderState -&gt; DecoderState -&gt; Bool
(DecoderState -&gt; DecoderState -&gt; Bool)
-&gt; (DecoderState -&gt; DecoderState -&gt; Bool) -&gt; Eq DecoderState
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: DecoderState -&gt; DecoderState -&gt; Bool
$c/= :: DecoderState -&gt; DecoderState -&gt; Bool
== :: DecoderState -&gt; DecoderState -&gt; Bool
$c== :: DecoderState -&gt; DecoderState -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></a></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109125"><span id="local-6989586621679109127"><span id="local-6989586621679109131"><span class="annot"><span class="annottext">Int -&gt; DecoderState -&gt; ShowS
[DecoderState] -&gt; ShowS
DecoderState -&gt; String
(Int -&gt; DecoderState -&gt; ShowS)
-&gt; (DecoderState -&gt; String)
-&gt; ([DecoderState] -&gt; ShowS)
-&gt; Show DecoderState
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [DecoderState] -&gt; ShowS
$cshowList :: [DecoderState] -&gt; ShowS
show :: DecoderState -&gt; String
$cshow :: DecoderState -&gt; String
showsPrec :: Int -&gt; DecoderState -&gt; ShowS
$cshowsPrec :: Int -&gt; DecoderState -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109099"><span id="local-6989586621679109103"><span id="local-6989586621679109107"><span id="local-6989586621679109111"><span id="local-6989586621679109115"><span id="local-6989586621679109119"><span id="local-6989586621679109123"><span class="annot"><span class="annottext">Integer -&gt; DecoderState
DecoderState -&gt; DecoderState
DecoderState -&gt; DecoderState -&gt; DecoderState
(DecoderState -&gt; DecoderState -&gt; DecoderState)
-&gt; (DecoderState -&gt; DecoderState -&gt; DecoderState)
-&gt; (DecoderState -&gt; DecoderState -&gt; DecoderState)
-&gt; (DecoderState -&gt; DecoderState)
-&gt; (DecoderState -&gt; DecoderState)
-&gt; (DecoderState -&gt; DecoderState)
-&gt; (Integer -&gt; DecoderState)
-&gt; Num DecoderState
forall a.
(a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (a -&gt; a)
-&gt; (Integer -&gt; a)
-&gt; Num a
fromInteger :: Integer -&gt; DecoderState
$cfromInteger :: Integer -&gt; DecoderState
signum :: DecoderState -&gt; DecoderState
$csignum :: DecoderState -&gt; DecoderState
abs :: DecoderState -&gt; DecoderState
$cabs :: DecoderState -&gt; DecoderState
negate :: DecoderState -&gt; DecoderState
$cnegate :: DecoderState -&gt; DecoderState
* :: DecoderState -&gt; DecoderState -&gt; DecoderState
$c* :: DecoderState -&gt; DecoderState -&gt; DecoderState
- :: DecoderState -&gt; DecoderState -&gt; DecoderState
$c- :: DecoderState -&gt; DecoderState -&gt; DecoderState
+ :: DecoderState -&gt; DecoderState -&gt; DecoderState
$c+ :: DecoderState -&gt; DecoderState -&gt; DecoderState
</span><a href="../../base/src/GHC.Num.html#Num"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Num</span></a></span></span></span></span></span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679109067"><span id="local-6989586621679109071"><span id="local-6989586621679109075"><span id="local-6989586621679109079"><span id="local-6989586621679109083"><span id="local-6989586621679109087"><span id="local-6989586621679109091"><span id="local-6989586621679109095"><span class="annot"><span class="annottext">Ptr DecoderState -&gt; IO DecoderState
Ptr DecoderState -&gt; Int -&gt; IO DecoderState
Ptr DecoderState -&gt; Int -&gt; DecoderState -&gt; IO ()
Ptr DecoderState -&gt; DecoderState -&gt; IO ()
DecoderState -&gt; Int
(DecoderState -&gt; Int)
-&gt; (DecoderState -&gt; Int)
-&gt; (Ptr DecoderState -&gt; Int -&gt; IO DecoderState)
-&gt; (Ptr DecoderState -&gt; Int -&gt; DecoderState -&gt; IO ())
-&gt; (forall b. Ptr b -&gt; Int -&gt; IO DecoderState)
-&gt; (forall b. Ptr b -&gt; Int -&gt; DecoderState -&gt; IO ())
-&gt; (Ptr DecoderState -&gt; IO DecoderState)
-&gt; (Ptr DecoderState -&gt; DecoderState -&gt; IO ())
-&gt; Storable DecoderState
forall b. Ptr b -&gt; Int -&gt; IO DecoderState
forall b. Ptr b -&gt; Int -&gt; DecoderState -&gt; IO ()
forall a.
(a -&gt; Int)
-&gt; (a -&gt; Int)
-&gt; (Ptr a -&gt; Int -&gt; IO a)
-&gt; (Ptr a -&gt; Int -&gt; a -&gt; IO ())
-&gt; (forall b. Ptr b -&gt; Int -&gt; IO a)
-&gt; (forall b. Ptr b -&gt; Int -&gt; a -&gt; IO ())
-&gt; (Ptr a -&gt; IO a)
-&gt; (Ptr a -&gt; a -&gt; IO ())
-&gt; Storable a
poke :: Ptr DecoderState -&gt; DecoderState -&gt; IO ()
$cpoke :: Ptr DecoderState -&gt; DecoderState -&gt; IO ()
peek :: Ptr DecoderState -&gt; IO DecoderState
$cpeek :: Ptr DecoderState -&gt; IO DecoderState
pokeByteOff :: forall b. Ptr b -&gt; Int -&gt; DecoderState -&gt; IO ()
$cpokeByteOff :: forall b. Ptr b -&gt; Int -&gt; DecoderState -&gt; IO ()
peekByteOff :: forall b. Ptr b -&gt; Int -&gt; IO DecoderState
$cpeekByteOff :: forall b. Ptr b -&gt; Int -&gt; IO DecoderState
pokeElemOff :: Ptr DecoderState -&gt; Int -&gt; DecoderState -&gt; IO ()
$cpokeElemOff :: Ptr DecoderState -&gt; Int -&gt; DecoderState -&gt; IO ()
peekElemOff :: Ptr DecoderState -&gt; Int -&gt; IO DecoderState
$cpeekElemOff :: Ptr DecoderState -&gt; Int -&gt; IO DecoderState
alignment :: DecoderState -&gt; Int
$calignment :: DecoderState -&gt; Int
sizeOf :: DecoderState -&gt; Int
$csizeOf :: DecoderState -&gt; Int
</span><a href="#local-6989586621679109067"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Storable</span></a></span></span></span></span></span></span></span></span></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>
</span><span id="line-279"></span><span class="hs-comment">-- | Decode, in a stream oriented way, a 'ByteString' containing UTF-8</span><span>
</span><span id="line-280"></span><span class="hs-comment">-- encoded text that is known to be valid.</span><span>
</span><span id="line-281"></span><span class="hs-comment">--</span><span>
</span><span id="line-282"></span><span class="hs-comment">-- If the input contains any invalid UTF-8 data, an exception will be</span><span>
</span><span id="line-283"></span><span class="hs-comment">-- thrown (either by this function or a continuation) that cannot be</span><span>
</span><span id="line-284"></span><span class="hs-comment">-- caught in pure code.  For more control over the handling of invalid</span><span>
</span><span id="line-285"></span><span class="hs-comment">-- data, use 'streamDecodeUtf8With'.</span><span>
</span><span id="line-286"></span><span class="hs-comment">--</span><span>
</span><span id="line-287"></span><span class="hs-comment">-- @since 1.0.0.0</span><span>
</span><span id="line-288"></span><span class="annot"><a href="Data.Text.Encoding.html#streamDecodeUtf8"><span class="hs-identifier hs-type">streamDecodeUtf8</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span><span>
</span><span id="line-293"></span><span id="streamDecodeUtf8"><span class="annot"><span class="annottext">streamDecodeUtf8 :: ByteString -&gt; Decoding
</span><a href="Data.Text.Encoding.html#streamDecodeUtf8"><span class="hs-identifier hs-var hs-var">streamDecodeUtf8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Decoding
</span><a href="Data.Text.Encoding.html#streamDecodeUtf8With"><span class="hs-identifier hs-var">streamDecodeUtf8With</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-comment">-- | Decode, in a stream oriented way, a lazy 'ByteString' containing UTF-8</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- encoded text.</span><span>
</span><span id="line-297"></span><span class="hs-comment">--</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- @since 1.0.0.0</span><span>
</span><span id="line-299"></span><span class="annot"><a href="Data.Text.Encoding.html#streamDecodeUtf8With"><span class="hs-identifier hs-type">streamDecodeUtf8With</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span><span>
</span><span id="line-304"></span><span id="streamDecodeUtf8With"><span class="annot"><span class="annottext">streamDecodeUtf8With :: OnDecodeError -&gt; ByteString -&gt; Decoding
</span><a href="Data.Text.Encoding.html#streamDecodeUtf8With"><span class="hs-identifier hs-var hs-var">streamDecodeUtf8With</span></a></span></span><span> </span><span id="local-6989586621679109063"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679109063"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; CodePoint -&gt; DecoderState -&gt; ByteString -&gt; Decoding
</span><a href="#local-6989586621679109062"><span class="hs-identifier hs-var">decodeChunk</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="../../bytestring/src/Data.ByteString.html#empty"><span class="hs-identifier hs-var">B.empty</span></a></span><span> </span><span class="annot"><span class="annottext">CodePoint
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><span class="hs-number">0</span></span><span>
</span><span id="line-305"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-306"></span><span>  </span><span class="hs-comment">-- We create a slightly larger than necessary buffer to accommodate a</span><span>
</span><span id="line-307"></span><span>  </span><span class="hs-comment">-- potential surrogate pair started in the last buffer (@undecoded0@), or</span><span>
</span><span id="line-308"></span><span>  </span><span class="hs-comment">-- replacement characters for each byte in @undecoded0@ if the</span><span>
</span><span id="line-309"></span><span>  </span><span class="hs-comment">-- sequence turns out to be invalid. There can be up to three bytes there,</span><span>
</span><span id="line-310"></span><span>  </span><span class="hs-comment">-- hence we allocate @len+3@ 16-bit words.</span><span>
</span><span id="line-311"></span><span>  </span><span class="annot"><a href="#local-6989586621679109062"><span class="hs-identifier hs-type">decodeChunk</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#CodePoint"><span class="hs-identifier hs-type">CodePoint</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#DecoderState"><span class="hs-identifier hs-type">DecoderState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-312"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span><span>
</span><span id="line-313"></span><span>  </span><span id="local-6989586621679109062"><span class="annot"><span class="annottext">decodeChunk :: ByteString -&gt; CodePoint -&gt; DecoderState -&gt; ByteString -&gt; Decoding
</span><a href="#local-6989586621679109062"><span class="hs-identifier hs-var hs-var">decodeChunk</span></a></span></span><span> </span><span id="local-6989586621679109060"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109060"><span class="hs-identifier hs-var">undecoded0</span></a></span></span><span> </span><span id="local-6989586621679109059"><span class="annot"><span class="annottext">CodePoint
</span><a href="#local-6989586621679109059"><span class="hs-identifier hs-var">codepoint0</span></a></span></span><span> </span><span id="local-6989586621679109058"><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109058"><span class="hs-identifier hs-var">state0</span></a></span></span><span> </span><span id="local-6989586621679109057"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109057"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; Decoding) -&gt; Decoding
forall r. ByteString -&gt; (ForeignPtr Word8 -&gt; Int -&gt; r) -&gt; r
</span><a href="Data.Text.Internal.ByteStringCompat.html#withBS"><span class="hs-identifier hs-var">withBS</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109057"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Decoding
</span><a href="#local-6989586621679109056"><span class="hs-identifier hs-var">aux</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-314"></span><span>    </span><span id="local-6989586621679109056"><span class="annot"><span class="annottext">aux :: ForeignPtr Word8 -&gt; Int -&gt; Decoding
</span><a href="#local-6989586621679109056"><span class="hs-identifier hs-var hs-var">aux</span></a></span></span><span> </span><span id="local-6989586621679109055"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109055"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679109054"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109054"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(forall s. ST s Decoding) -&gt; Decoding
forall a. (forall s. ST s a) -&gt; a
</span><a href="../../base/src/GHC.ST.html#runST"><span class="hs-identifier hs-var">runST</span></a></span><span> </span><span class="annot"><span class="annottext">((forall s. ST s Decoding) -&gt; Decoding)
-&gt; (forall s. ST s Decoding) -&gt; Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IO Decoding -&gt; ST s Decoding
forall a s. IO a -&gt; ST s a
</span><a href="../../base/src/GHC.IO.html#unsafeIOToST"><span class="hs-identifier hs-var">unsafeIOToST</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Decoding -&gt; ST s Decoding)
-&gt; (MArray s -&gt; IO Decoding) -&gt; MArray s -&gt; ST s Decoding
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s -&gt; IO Decoding
forall s. MArray s -&gt; IO Decoding
</span><a href="#local-6989586621679109050"><span class="hs-identifier hs-var">decodeChunkToBuffer</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(MArray s -&gt; ST s Decoding) -&gt; ST s (MArray s) -&gt; ST s Decoding
forall (m :: * -&gt; *) a b. Monad m =&gt; (a -&gt; m b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3D%3C%3C"><span class="hs-operator hs-var">=&lt;&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; ST s (MArray s)
forall s. Int -&gt; ST s (MArray s)
</span><a href="Data.Text.Array.html#new"><span class="hs-identifier hs-var">A.new</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109054"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-315"></span><span>       </span><span class="hs-keyword">where</span><span>
</span><span id="line-316"></span><span>        </span><span id="local-6989586621679109454"><span class="annot"><a href="#local-6989586621679109050"><span class="hs-identifier hs-type">decodeChunkToBuffer</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Array.html#MArray"><span class="hs-identifier hs-type">A.MArray</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679109454"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#Decoding"><span class="hs-identifier hs-type">Decoding</span></a></span></span><span>
</span><span id="line-317"></span><span>        </span><span id="local-6989586621679109050"><span class="annot"><span class="annottext">decodeChunkToBuffer :: forall s. MArray s -&gt; IO Decoding
</span><a href="#local-6989586621679109050"><span class="hs-identifier hs-var hs-var">decodeChunkToBuffer</span></a></span></span><span> </span><span id="local-6989586621679109044"><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109044"><span class="hs-identifier hs-var">dest</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Decoding) -&gt; IO Decoding
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679109055"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Decoding) -&gt; IO Decoding)
-&gt; (Ptr Word8 -&gt; IO Decoding) -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109043"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109043"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-318"></span><span>          </span><span class="annot"><span class="annottext">CSize -&gt; (Ptr CSize -&gt; IO Decoding) -&gt; IO Decoding
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize
</span><span class="hs-number">0</span></span><span class="hs-glyph">::</span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr CSize -&gt; IO Decoding) -&gt; IO Decoding)
-&gt; (Ptr CSize -&gt; IO Decoding) -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109042"><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109042"><span class="hs-identifier hs-var">destOffPtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-319"></span><span>          </span><span class="annot"><span class="annottext">CodePoint -&gt; (Ptr CodePoint -&gt; IO Decoding) -&gt; IO Decoding
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">CodePoint
</span><a href="#local-6989586621679109059"><span class="hs-identifier hs-var">codepoint0</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr CodePoint -&gt; IO Decoding) -&gt; IO Decoding)
-&gt; (Ptr CodePoint -&gt; IO Decoding) -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109041"><span class="annot"><span class="annottext">Ptr CodePoint
</span><a href="#local-6989586621679109041"><span class="hs-identifier hs-var">codepointPtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-320"></span><span>          </span><span class="annot"><span class="annottext">DecoderState -&gt; (Ptr DecoderState -&gt; IO Decoding) -&gt; IO Decoding
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109058"><span class="hs-identifier hs-var">state0</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr DecoderState -&gt; IO Decoding) -&gt; IO Decoding)
-&gt; (Ptr DecoderState -&gt; IO Decoding) -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109040"><span class="annot"><span class="annottext">Ptr DecoderState
</span><a href="#local-6989586621679109040"><span class="hs-identifier hs-var">statePtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-321"></span><span>          </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (Ptr (Ptr Word8) -&gt; IO Decoding) -&gt; IO Decoding
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="../../base/src/GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr (Ptr Word8) -&gt; IO Decoding) -&gt; IO Decoding)
-&gt; (Ptr (Ptr Word8) -&gt; IO Decoding) -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679109039"><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679109039"><span class="hs-identifier hs-var">curPtrPtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-322"></span><span>            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679109038"><span class="annot"><span class="annottext">end :: Ptr b
</span><a href="#local-6989586621679109038"><span class="hs-identifier hs-var hs-var">end</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109043"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679109054"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-323"></span><span>                </span><span id="local-6989586621679109006"><span class="annot"><span class="annottext">loop :: Ptr Word8 -&gt; IO Decoding
</span><a href="#local-6989586621679109006"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span id="local-6989586621679109005"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109005"><span class="hs-identifier hs-var">curPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-324"></span><span>                  </span><span id="local-6989586621679109004"><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109004"><span class="hs-identifier hs-var">prevState</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr DecoderState -&gt; IO DecoderState
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr DecoderState
</span><a href="#local-6989586621679109040"><span class="hs-identifier hs-var">statePtr</span></a></span><span>
</span><span id="line-325"></span><span>                  </span><span class="annot"><span class="annottext">Ptr (Ptr Word8) -&gt; Ptr Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679109039"><span class="hs-identifier hs-var">curPtrPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109005"><span class="hs-identifier hs-var">curPtr</span></a></span><span>
</span><span id="line-326"></span><span>                  </span><span id="local-6989586621679109003"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109003"><span class="hs-identifier hs-var">lastPtr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MutableByteArray# s
-&gt; Ptr CSize
-&gt; Ptr (Ptr Word8)
-&gt; Ptr Word8
-&gt; Ptr CodePoint
-&gt; Ptr DecoderState
-&gt; IO (Ptr Word8)
forall s.
MutableByteArray# s
-&gt; Ptr CSize
-&gt; Ptr (Ptr Word8)
-&gt; Ptr Word8
-&gt; Ptr CodePoint
-&gt; Ptr DecoderState
-&gt; IO (Ptr Word8)
</span><a href="Data.Text.Encoding.html#c_decode_utf8_with_state"><span class="hs-identifier hs-var">c_decode_utf8_with_state</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">MArray s -&gt; MutableByteArray# s
forall s. MArray s -&gt; MutableByteArray# s
</span><a href="Data.Text.Array.html#maBA"><span class="hs-identifier hs-var hs-var">A.maBA</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109044"><span class="hs-identifier hs-var">dest</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109042"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span>
</span><span id="line-327"></span><span>                             </span><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679109039"><span class="hs-identifier hs-var">curPtrPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
forall {b}. Ptr b
</span><a href="#local-6989586621679109038"><span class="hs-identifier hs-var">end</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CodePoint
</span><a href="#local-6989586621679109041"><span class="hs-identifier hs-var">codepointPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr DecoderState
</span><a href="#local-6989586621679109040"><span class="hs-identifier hs-var">statePtr</span></a></span><span>
</span><span id="line-328"></span><span>                  </span><span id="local-6989586621679109001"><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109001"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr DecoderState -&gt; IO DecoderState
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr DecoderState
</span><a href="#local-6989586621679109040"><span class="hs-identifier hs-var">statePtr</span></a></span><span>
</span><span id="line-329"></span><span>                  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109001"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-330"></span><span>                    </span><span class="hs-identifier">UTF8_REJECT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-331"></span><span>                      </span><span class="hs-comment">-- We encountered an encoding error</span><span>
</span><span id="line-332"></span><span>                      </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">statePtr</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-333"></span><span>                      </span><span class="hs-keyword">let</span><span> </span><span class="hs-identifier">skipByte</span><span> </span><span class="hs-identifier">x</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">onErr</span><span> </span><span class="hs-identifier">desc</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">x</span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-334"></span><span>                            </span><span class="hs-identifier">Nothing</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">return</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-335"></span><span>                            </span><span class="hs-identifier">Just</span><span> </span><span class="hs-identifier">c</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-336"></span><span>                              </span><span class="hs-identifier">destOff</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">destOffPtr</span><span>
</span><span id="line-337"></span><span>                              </span><span class="hs-identifier">w</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">unsafeSTToIO</span><span> </span><span class="hs-operator">$</span><span>
</span><span id="line-338"></span><span>                                   </span><span class="hs-identifier">unsafeWrite</span><span> </span><span class="hs-identifier">dest</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">cSizeToInt</span><span> </span><span class="hs-identifier">destOff</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="hs-keyword">safe</span><span> </span><span class="hs-identifier">c</span><span class="hs-special">)</span><span>
</span><span id="line-339"></span><span>                              </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">destOffPtr</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">destOff</span><span> </span><span class="hs-operator">+</span><span> </span><span class="hs-identifier">intToCSize</span><span> </span><span class="hs-identifier">w</span><span class="hs-special">)</span><span>
</span><span id="line-340"></span><span>                      </span><span class="hs-keyword">if</span><span> </span><span class="hs-identifier">ptr</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">lastPtr</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">prevState</span><span> </span><span class="hs-operator">/=</span><span> </span><span class="hs-identifier">UTF8_ACCEPT</span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-341"></span><span>                        </span><span class="hs-comment">-- If we can't complete the sequence @undecoded0@ from</span><span>
</span><span id="line-342"></span><span>                        </span><span class="hs-comment">-- the previous chunk, we invalidate the bytes from</span><span>
</span><span id="line-343"></span><span>                        </span><span class="hs-comment">-- @undecoded0@ and retry decoding the current chunk from</span><span>
</span><span id="line-344"></span><span>                        </span><span class="hs-comment">-- the initial state.</span><span>
</span><span id="line-345"></span><span>                        </span><span class="hs-identifier">traverse_</span><span> </span><span class="hs-identifier">skipByte</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">B.unpack</span><span> </span><span class="hs-identifier">undecoded0</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-346"></span><span>                        </span><span class="hs-identifier">loop</span><span> </span><span class="hs-identifier">lastPtr</span><span>
</span><span id="line-347"></span><span>                      </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-348"></span><span>                        </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">lastPtr</span><span> </span><span class="hs-operator">&gt;&gt;=</span><span> </span><span class="hs-identifier">skipByte</span><span>
</span><span id="line-349"></span><span>                        </span><span class="hs-identifier">loop</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">lastPtr</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-number">1</span><span class="hs-special">)</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span>                    </span><span class="annot"><span class="annottext">DecoderState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-352"></span><span>                      </span><span class="hs-comment">-- We encountered the end of the buffer while decoding</span><span>
</span><span id="line-353"></span><span>                      </span><span id="local-6989586621679108985"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679108985"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CSize -&gt; IO CSize
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CSize
</span><a href="#local-6989586621679109042"><span class="hs-identifier hs-var">destOffPtr</span></a></span><span>
</span><span id="line-354"></span><span>                      </span><span id="local-6989586621679108984"><span class="annot"><span class="annottext">CodePoint
</span><a href="#local-6989586621679108984"><span class="hs-identifier hs-var">codepoint</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CodePoint -&gt; IO CodePoint
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CodePoint
</span><a href="#local-6989586621679109041"><span class="hs-identifier hs-var">codepointPtr</span></a></span><span>
</span><span id="line-355"></span><span>                      </span><span id="local-6989586621679108983"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108983"><span class="hs-identifier hs-var">chunkText</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ST s Text -&gt; IO Text
forall s a. ST s a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#unsafeSTToIO"><span class="hs-identifier hs-var">unsafeSTToIO</span></a></span><span> </span><span class="annot"><span class="annottext">(ST s Text -&gt; IO Text) -&gt; ST s Text -&gt; IO Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-356"></span><span>                          </span><span id="local-6989586621679108982"><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108982"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">MArray s -&gt; ST s Array
forall s. MArray s -&gt; ST s Array
</span><a href="Data.Text.Array.html#unsafeFreeze"><span class="hs-identifier hs-var">A.unsafeFreeze</span></a></span><span> </span><span class="annot"><span class="annottext">MArray s
</span><a href="#local-6989586621679109044"><span class="hs-identifier hs-var">dest</span></a></span><span>
</span><span id="line-357"></span><span>                          </span><span class="annot"><span class="annottext">Text -&gt; ST s Text
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; ST s Text) -&gt; Text -&gt; ST s Text
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Int -&gt; Text
</span><a href="Data.Text.Internal.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108982"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
</span><a href="Data.Text.Encoding.html#cSizeToInt"><span class="hs-identifier hs-var">cSizeToInt</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679108985"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-358"></span><span>                      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679108979"><span class="annot"><span class="annottext">left :: Int
</span><a href="#local-6989586621679108979"><span class="hs-identifier hs-var hs-var">left</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109003"><span class="hs-identifier hs-var">lastPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int
forall a b. Ptr a -&gt; Ptr b -&gt; Int
</span><a href="../../base/src/GHC.Ptr.html#minusPtr"><span class="hs-operator hs-var">`minusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109043"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-359"></span><span>                          </span><span class="hs-glyph">!</span><span id="local-6989586621679108972"><span class="annot"><span class="annottext">undecoded :: ByteString
</span><a href="#local-6989586621679108972"><span class="hs-identifier hs-var hs-var">undecoded</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109001"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-360"></span><span>                            </span><span class="hs-identifier">UTF8_ACCEPT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">B.empty</span><span>
</span><span id="line-361"></span><span>                            </span><span class="annot"><span class="annottext">DecoderState
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108979"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109004"><span class="hs-identifier hs-var">prevState</span></a></span><span> </span><span class="annot"><span class="annottext">DecoderState -&gt; DecoderState -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="hs-identifier">UTF8_ACCEPT</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">B.append</span><span> </span><span class="hs-identifier">undecoded0</span><span> </span><span class="hs-identifier">bs</span><span>
</span><span id="line-362"></span><span>                              </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ByteString -&gt; ByteString
</span><a href="../../bytestring/src/Data.ByteString.html#drop"><span class="hs-identifier hs-var">B.drop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108979"><span class="hs-identifier hs-var">left</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679109057"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-363"></span><span>                      </span><span class="annot"><span class="annottext">Decoding -&gt; IO Decoding
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Decoding -&gt; IO Decoding) -&gt; Decoding -&gt; IO Decoding
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Text -&gt; ByteString -&gt; (ByteString -&gt; Decoding) -&gt; Decoding
</span><a href="Data.Text.Encoding.html#Some"><span class="hs-identifier hs-var">Some</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108983"><span class="hs-identifier hs-var">chunkText</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108972"><span class="hs-identifier hs-var">undecoded</span></a></span><span>
</span><span id="line-364"></span><span>                               </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString -&gt; CodePoint -&gt; DecoderState -&gt; ByteString -&gt; Decoding
</span><a href="#local-6989586621679109062"><span class="hs-identifier hs-var">decodeChunk</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108972"><span class="hs-identifier hs-var">undecoded</span></a></span><span> </span><span class="annot"><span class="annottext">CodePoint
</span><a href="#local-6989586621679108984"><span class="hs-identifier hs-var">codepoint</span></a></span><span> </span><span class="annot"><span class="annottext">DecoderState
</span><a href="#local-6989586621679109001"><span class="hs-identifier hs-var">state</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-365"></span><span>            </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Decoding
</span><a href="#local-6989586621679109006"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679109043"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-366"></span><span>  </span><span id="local-6989586621679108992"><span class="annot"><span class="annottext">desc :: String
</span><a href="#local-6989586621679108992"><span class="hs-identifier hs-var hs-var">desc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.Text.Internal.Encoding.streamDecodeUtf8With: Invalid UTF-8 stream&quot;</span></span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span class="hs-comment">-- | Decode a 'ByteString' containing UTF-8 encoded text that is known</span><span>
</span><span id="line-369"></span><span class="hs-comment">-- to be valid.</span><span>
</span><span id="line-370"></span><span class="hs-comment">--</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- If the input contains any invalid UTF-8 data, an exception will be</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- thrown that cannot be caught in pure code.  For more control over</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- the handling of invalid data, use 'decodeUtf8'' or</span><span>
</span><span id="line-374"></span><span class="hs-comment">-- 'decodeUtf8With'.</span><span>
</span><span id="line-375"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-identifier hs-type">decodeUtf8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-376"></span><span id="decodeUtf8"><span class="annot"><span class="annottext">decodeUtf8 :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-identifier hs-var hs-var">decodeUtf8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf8With"><span class="hs-identifier hs-var">decodeUtf8With</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-377"></span><span class="hs-pragma">{-# INLINE</span><span class="hs-pragma">[</span><span class="hs-pragma">0</span><span class="hs-pragma">]</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-pragma hs-type">decodeUtf8</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-378"></span><span class="hs-pragma">{-# RULES</span><span> </span><span class="annot"><span class="hs-pragma">&quot;STREAM stream/decodeUtf8 fusion&quot;</span></span><span> </span><span class="hs-pragma">[</span><span class="hs-pragma">1</span><span class="hs-pragma">]</span><span>
</span><span id="line-379"></span><span>    </span><span class="hs-pragma">forall</span><span> </span><span id="local-6989586621679108969"><span class="annot"><a href="#local-6989586621679108969"><span class="hs-pragma hs-var">bs</span></a></span></span><span class="hs-pragma">.</span><span> </span><span class="annot"><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-pragma hs-type">F.stream</span></a></span><span> </span><span class="hs-pragma">(</span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8"><span class="hs-pragma hs-type">decodeUtf8</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679108969"><span class="hs-pragma hs-type">bs</span></a></span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">=</span><span> </span><span class="annot"><a href="Data.Text.Internal.Encoding.Fusion.html#streamUtf8"><span class="hs-pragma hs-type">E.streamUtf8</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-pragma hs-type">strictDecode</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679108969"><span class="hs-pragma hs-type">bs</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-380"></span><span>
</span><span id="line-381"></span><span class="hs-comment">-- | Decode a 'ByteString' containing UTF-8 encoded text.</span><span>
</span><span id="line-382"></span><span class="hs-comment">--</span><span>
</span><span id="line-383"></span><span class="hs-comment">-- If the input contains any invalid UTF-8 data, the relevant</span><span>
</span><span id="line-384"></span><span class="hs-comment">-- exception will be returned, otherwise the decoded text.</span><span>
</span><span id="line-385"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8%27"><span class="hs-identifier hs-type">decodeUtf8'</span></a></span><span> </span><span class="hs-glyph">::</span><span class="hs-cpp">
#if defined(ASSERTS)
</span><span>  </span><span class="hs-identifier">HasCallStack</span><span> </span><span class="hs-glyph">=&gt;</span><span class="hs-cpp">
#endif
</span><span>  </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#UnicodeException"><span class="hs-identifier hs-type">UnicodeException</span></a></span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-390"></span><span id="decodeUtf8%27"><span class="annot"><span class="annottext">decodeUtf8' :: ByteString -&gt; Either UnicodeException Text
</span><a href="Data.Text.Encoding.html#decodeUtf8%27"><span class="hs-identifier hs-var hs-var">decodeUtf8'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (Either UnicodeException Text) -&gt; Either UnicodeException Text
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO (Either UnicodeException Text) -&gt; Either UnicodeException Text)
-&gt; (ByteString -&gt; IO (Either UnicodeException Text))
-&gt; ByteString
-&gt; Either UnicodeException Text
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IO Text -&gt; IO (Either UnicodeException Text)
forall e a. Exception e =&gt; IO a -&gt; IO (Either e a)
</span><a href="../../base/src/Control.Exception.Base.html#try"><span class="hs-identifier hs-var">try</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Text -&gt; IO (Either UnicodeException Text))
-&gt; (ByteString -&gt; IO Text)
-&gt; ByteString
-&gt; IO (Either UnicodeException Text)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Text -&gt; IO Text
forall a. a -&gt; IO a
</span><a href="../../base/src/GHC.IO.html#evaluate"><span class="hs-identifier hs-var">evaluate</span></a></span><span> </span><span class="annot"><span class="annottext">(Text -&gt; IO Text) -&gt; (ByteString -&gt; Text) -&gt; ByteString -&gt; IO Text
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf8With"><span class="hs-identifier hs-var">decodeUtf8With</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-391"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf8%27"><span class="hs-pragma hs-type">decodeUtf8'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span class="hs-comment">-- | Encode text to a ByteString 'B.Builder' using UTF-8 encoding.</span><span>
</span><span id="line-394"></span><span class="hs-comment">--</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- @since 1.1.0.0</span><span>
</span><span id="line-396"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8Builder"><span class="hs-identifier hs-type">encodeUtf8Builder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#Builder"><span class="hs-identifier hs-type">B.Builder</span></a></span><span>
</span><span id="line-397"></span><span id="encodeUtf8Builder"><span class="annot"><span class="annottext">encodeUtf8Builder :: Text -&gt; Builder
</span><a href="Data.Text.Encoding.html#encodeUtf8Builder"><span class="hs-identifier hs-var hs-var">encodeUtf8Builder</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BoundedPrim Word8 -&gt; Text -&gt; Builder
</span><a href="Data.Text.Encoding.html#encodeUtf8BuilderEscaped"><span class="hs-identifier hs-var">encodeUtf8BuilderEscaped</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FixedPrim Word8 -&gt; BoundedPrim Word8
forall a. FixedPrim a -&gt; BoundedPrim a
</span><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Internal.html#liftFixedToBounded"><span class="hs-identifier hs-var">BP.liftFixedToBounded</span></a></span><span> </span><span class="annot"><span class="annottext">FixedPrim Word8
</span><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Binary.html#word8"><span class="hs-identifier hs-var">BP.word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>
</span><span id="line-399"></span><span class="hs-comment">-- | Encode text using UTF-8 encoding and escape the ASCII characters using</span><span>
</span><span id="line-400"></span><span class="hs-comment">-- a 'BP.BoundedPrim'.</span><span>
</span><span id="line-401"></span><span class="hs-comment">--</span><span>
</span><span id="line-402"></span><span class="hs-comment">-- Use this function is to implement efficient encoders for text-based formats</span><span>
</span><span id="line-403"></span><span class="hs-comment">-- like JSON or HTML.</span><span>
</span><span id="line-404"></span><span class="hs-comment">--</span><span>
</span><span id="line-405"></span><span class="hs-comment">-- @since 1.1.0.0</span><span>
</span><span id="line-406"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8BuilderEscaped"><span class="hs-pragma hs-type">encodeUtf8BuilderEscaped</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-407"></span><span class="hs-comment">-- TODO: Extend documentation with references to source code in @blaze-html@</span><span>
</span><span id="line-408"></span><span class="hs-comment">-- or @aeson@ that uses this function.</span><span>
</span><span id="line-409"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8BuilderEscaped"><span class="hs-identifier hs-type">encodeUtf8BuilderEscaped</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Internal.html#BoundedPrim"><span class="hs-identifier hs-type">BP.BoundedPrim</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#Builder"><span class="hs-identifier hs-type">B.Builder</span></a></span><span>
</span><span id="line-410"></span><span id="encodeUtf8BuilderEscaped"><span class="annot"><span class="annottext">encodeUtf8BuilderEscaped :: BoundedPrim Word8 -&gt; Text -&gt; Builder
</span><a href="Data.Text.Encoding.html#encodeUtf8BuilderEscaped"><span class="hs-identifier hs-var hs-var">encodeUtf8BuilderEscaped</span></a></span></span><span> </span><span id="local-6989586621679108964"><span class="annot"><span class="annottext">BoundedPrim Word8
</span><a href="#local-6989586621679108964"><span class="hs-identifier hs-var">be</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-411"></span><span>    </span><span class="hs-comment">-- manual eta-expansion to ensure inlining works as expected</span><span>
</span><span id="line-412"></span><span>    </span><span class="hs-glyph">\</span><span id="local-6989586621679108963"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108963"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(forall r. BuildStep r -&gt; BuildStep r) -&gt; Builder
</span><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#builder"><span class="hs-identifier hs-var">B.builder</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text
-&gt; (BufferRange -&gt; IO (BuildSignal r))
-&gt; BufferRange
-&gt; IO (BuildSignal r)
forall {a}.
Text
-&gt; (BufferRange -&gt; IO (BuildSignal a))
-&gt; BufferRange
-&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108961"><span class="hs-identifier hs-var">mkBuildstep</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108963"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-413"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-414"></span><span>    </span><span id="local-6989586621679108958"><span class="annot"><span class="annottext">bound :: Int
</span><a href="#local-6989586621679108958"><span class="hs-identifier hs-var hs-var">bound</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#max"><span class="hs-identifier hs-var">max</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Int) -&gt; Int -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BoundedPrim Word8 -&gt; Int
forall a. BoundedPrim a -&gt; Int
</span><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Internal.html#sizeBound"><span class="hs-identifier hs-var">BP.sizeBound</span></a></span><span> </span><span class="annot"><span class="annottext">BoundedPrim Word8
</span><a href="#local-6989586621679108964"><span class="hs-identifier hs-var">be</span></a></span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span>    </span><span id="local-6989586621679108961"><span class="annot"><span class="annottext">mkBuildstep :: Text
-&gt; (BufferRange -&gt; IO (BuildSignal a))
-&gt; BufferRange
-&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108961"><span class="hs-identifier hs-var hs-var">mkBuildstep</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span id="local-6989586621679108954"><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108954"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span id="local-6989586621679108953"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108953"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679108952"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108952"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108951"><span class="annot"><span class="annottext">BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108951"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-417"></span><span>        </span><span class="annot"><span class="annottext">Int -&gt; BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108950"><span class="hs-identifier hs-var">outerLoop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108953"><span class="hs-identifier hs-var">off</span></a></span><span>
</span><span id="line-418"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-419"></span><span>        </span><span id="local-6989586621679108948"><span class="annot"><span class="annottext">iend :: Int
</span><a href="#local-6989586621679108948"><span class="hs-identifier hs-var hs-var">iend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108953"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108952"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span>        </span><span id="local-6989586621679108950"><span class="annot"><span class="annottext">outerLoop :: Int -&gt; BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108950"><span class="hs-identifier hs-var hs-var">outerLoop</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108941"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108940"><span class="annot"><span class="annottext">br :: BufferRange
</span><a href="#local-6989586621679108940"><span class="hs-identifier hs-var">br</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#BufferRange"><span class="hs-identifier hs-type">B.BufferRange</span></a></span><span> </span><span id="local-6989586621679108938"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108938"><span class="hs-identifier hs-var">op0</span></a></span></span><span> </span><span id="local-6989586621679108937"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108937"><span class="hs-identifier hs-var">ope</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-422"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108948"><span class="hs-identifier hs-var">iend</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108951"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">BufferRange
</span><a href="#local-6989586621679108940"><span class="hs-identifier hs-var">br</span></a></span><span>
</span><span id="line-423"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108936"><span class="hs-identifier hs-var">outRemaining</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E"><span class="hs-operator hs-var">&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108935"><span class="hs-identifier hs-var">goPartial</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#min"><span class="hs-identifier hs-var">min</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108936"><span class="hs-identifier hs-var">outRemaining</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108933"><span class="hs-identifier hs-var">inpRemaining</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-424"></span><span>          </span><span class="hs-comment">-- TODO: Use a loop with an integrated bound's check if outRemaining</span><span>
</span><span id="line-425"></span><span>          </span><span class="hs-comment">-- is smaller than 8, as this will save on divisions.</span><span>
</span><span id="line-426"></span><span>          </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">BuildSignal a -&gt; IO (BuildSignal a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(BuildSignal a -&gt; IO (BuildSignal a))
-&gt; BuildSignal a -&gt; IO (BuildSignal a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int
-&gt; Ptr Word8
-&gt; (BufferRange -&gt; IO (BuildSignal a))
-&gt; BuildSignal a
forall a. Int -&gt; Ptr Word8 -&gt; BuildStep a -&gt; BuildSignal a
</span><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#bufferFull"><span class="hs-identifier hs-var">B.bufferFull</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108958"><span class="hs-identifier hs-var">bound</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108938"><span class="hs-identifier hs-var">op0</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108950"><span class="hs-identifier hs-var">outerLoop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-427"></span><span>          </span><span class="hs-keyword">where</span><span>
</span><span id="line-428"></span><span>            </span><span id="local-6989586621679108936"><span class="annot"><span class="annottext">outRemaining :: Int
</span><a href="#local-6989586621679108936"><span class="hs-identifier hs-var hs-var">outRemaining</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108937"><span class="hs-identifier hs-var">ope</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int
forall a b. Ptr a -&gt; Ptr b -&gt; Int
</span><a href="../../base/src/GHC.Ptr.html#minusPtr"><span class="hs-operator hs-var">`minusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108938"><span class="hs-identifier hs-var">op0</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Integral a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Real.html#div"><span class="hs-operator hs-var">`div`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108958"><span class="hs-identifier hs-var">bound</span></a></span><span>
</span><span id="line-429"></span><span>            </span><span id="local-6989586621679108933"><span class="annot"><span class="annottext">inpRemaining :: Int
</span><a href="#local-6989586621679108933"><span class="hs-identifier hs-var hs-var">inpRemaining</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108948"><span class="hs-identifier hs-var">iend</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span><span>
</span><span id="line-430"></span><span>
</span><span id="line-431"></span><span>            </span><span id="local-6989586621679108935"><span class="annot"><span class="annottext">goPartial :: Int -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108935"><span class="hs-identifier hs-var hs-var">goPartial</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108928"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108928"><span class="hs-identifier hs-var">iendTmp</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108941"><span class="hs-identifier hs-var">i0</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108938"><span class="hs-identifier hs-var">op0</span></a></span><span>
</span><span id="line-432"></span><span>              </span><span class="hs-keyword">where</span><span>
</span><span id="line-433"></span><span>                </span><span id="local-6989586621679108927"><span class="annot"><span class="annottext">go :: Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108849"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679108848"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span></span><span>
</span><span id="line-434"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C"><span class="hs-operator hs-var">&lt;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108928"><span class="hs-identifier hs-var">iendTmp</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Word16
</span><a href="Data.Text.Array.html#unsafeIndex"><span class="hs-identifier hs-var">A.unsafeIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108954"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-435"></span><span>                      </span><span id="local-6989586621679108845"><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x7F</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-436"></span><span>                            </span><span class="annot"><span class="annottext">BoundedPrim Word8 -&gt; Word8 -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
forall a. BoundedPrim a -&gt; a -&gt; Ptr Word8 -&gt; IO (Ptr Word8)
</span><a href="../../bytestring/src/Data.ByteString.Builder.Prim.Internal.html#runB"><span class="hs-identifier hs-var">BP.runB</span></a></span><span> </span><span class="annot"><span class="annottext">BoundedPrim Word8
</span><a href="#local-6989586621679108964"><span class="hs-identifier hs-var">be</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16 -&gt; Word8
</span><a href="Data.Text.Encoding.html#word16ToWord8"><span class="hs-identifier hs-var">word16ToWord8</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">IO (Ptr Word8)
-&gt; (Ptr Word8 -&gt; IO (BuildSignal a)) -&gt; IO (BuildSignal a)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-437"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x7FF</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-438"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">(Word16 -&gt; IO ()) -&gt; Word16 -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Int -&gt; Word16
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xC0</span></span><span>
</span><span id="line-439"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">(Word16 -&gt; IO ()) -&gt; Word16 -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x3f</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-440"></span><span>                            </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-441"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xD800</span></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xDBFF</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-442"></span><span>                            </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679108838"><span class="annot"><span class="annottext">c :: Int
</span><a href="#local-6989586621679108838"><span class="hs-identifier hs-var hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="Data.Text.Internal.Unsafe.Char.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">(Char -&gt; Int) -&gt; Char -&gt; Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Char
</span><a href="Data.Text.Internal.Encoding.Utf16.html#chr2"><span class="hs-identifier hs-var">U16.chr2</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array -&gt; Int -&gt; Word16
</span><a href="Data.Text.Array.html#unsafeIndex"><span class="hs-identifier hs-var">A.unsafeIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108954"><span class="hs-identifier hs-var">arr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-443"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108838"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">18</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0xF0</span></span><span>
</span><span id="line-444"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108838"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">12</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-445"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108838"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-446"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; IO ()) -&gt; Int -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108838"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-447"></span><span>                            </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span class="hs-special">)</span><span>
</span><span id="line-448"></span><span>                        </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-449"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">(Word16 -&gt; IO ()) -&gt; Word16 -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Int -&gt; Word16
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">12</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0xE0</span></span><span>
</span><span id="line-450"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">(Word16 -&gt; IO ()) -&gt; Word16 -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Int -&gt; Word16
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">6</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-451"></span><span>                            </span><span class="annot"><span class="annottext">forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var">poke8</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(Word16 -&gt; IO ()) -&gt; Word16 -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word16
</span><a href="#local-6989586621679108845"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Bits a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/Data.Bits.html#.%26."><span class="hs-operator hs-var">.&amp;.</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x3F</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word16 -&gt; Word16
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Word16
</span><span class="hs-number">0x80</span></span><span>
</span><span id="line-452"></span><span>                            </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word8 -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108927"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span>
</span><span id="line-453"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-454"></span><span>                      </span><span class="annot"><span class="annottext">Int -&gt; BufferRange -&gt; IO (BuildSignal a)
</span><a href="#local-6989586621679108950"><span class="hs-identifier hs-var">outerLoop</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108849"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; BufferRange
</span><a href="../../bytestring/src/Data.ByteString.Builder.Internal.html#BufferRange"><span class="hs-identifier hs-var">B.BufferRange</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108937"><span class="hs-identifier hs-var">ope</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-455"></span><span>                  </span><span class="hs-keyword">where</span><span>
</span><span id="line-456"></span><span>                    </span><span class="hs-comment">-- Take care, a is either Word16 or Int above</span><span>
</span><span id="line-457"></span><span>                    </span><span id="local-6989586621679109424"><span class="annot"><a href="#local-6989586621679108841"><span class="hs-identifier hs-type">poke8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Real.html#Integral"><span class="hs-identifier hs-type">Integral</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679109424"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679109424"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-458"></span><span>                    </span><span id="local-6989586621679108841"><span class="annot"><span class="annottext">poke8 :: forall a. Integral a =&gt; Int -&gt; a -&gt; IO ()
</span><a href="#local-6989586621679108841"><span class="hs-identifier hs-var hs-var">poke8</span></a></span></span><span> </span><span id="local-6989586621679108832"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108832"><span class="hs-identifier hs-var">j</span></a></span></span><span> </span><span id="local-6989586621679108831"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679108831"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108848"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108832"><span class="hs-identifier hs-var">j</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679108831"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span class="hs-comment">-- | Encode text using UTF-8 encoding.</span><span>
</span><span id="line-461"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf8"><span class="hs-identifier hs-type">encodeUtf8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-462"></span><span id="encodeUtf8"><span class="annot"><span class="annottext">encodeUtf8 :: Text -&gt; ByteString
</span><a href="Data.Text.Encoding.html#encodeUtf8"><span class="hs-identifier hs-var hs-var">encodeUtf8</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span id="local-6989586621679108830"><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108830"><span class="hs-identifier hs-var">arr</span></a></span></span><span> </span><span id="local-6989586621679108829"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108829"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679108828"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108828"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108828"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="../../bytestring/src/Data.ByteString.html#empty"><span class="hs-identifier hs-var">B.empty</span></a></span><span>
</span><span id="line-464"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ByteString -&gt; ByteString
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO ByteString -&gt; ByteString) -&gt; IO ByteString -&gt; ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-465"></span><span>  </span><span id="local-6989586621679108827"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108827"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="../../bytestring/src/Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">B.mallocByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108828"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">3</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- see https://github.com/haskell/text/issues/194 for why len*3 is enough</span><span>
</span><span id="line-466"></span><span>  </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108827"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString)
-&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679108824"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108824"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-467"></span><span>    </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; (Ptr (Ptr Word8) -&gt; IO ByteString) -&gt; IO ByteString
forall a b. Storable a =&gt; a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/Foreign.Marshal.Utils.html#with"><span class="hs-identifier hs-var">with</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108824"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr (Ptr Word8) -&gt; IO ByteString) -&gt; IO ByteString)
-&gt; (Ptr (Ptr Word8) -&gt; IO ByteString) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679108823"><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679108823"><span class="hs-identifier hs-var">destPtr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-468"></span><span>      </span><span class="annot"><span class="annottext">Ptr (Ptr Word8) -&gt; ByteArray# -&gt; CSize -&gt; CSize -&gt; IO ()
</span><a href="Data.Text.Encoding.html#c_encode_utf8"><span class="hs-identifier hs-var">c_encode_utf8</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679108823"><span class="hs-identifier hs-var">destPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Array -&gt; ByteArray#
</span><a href="Data.Text.Array.html#aBA"><span class="hs-identifier hs-var hs-var">A.aBA</span></a></span><span> </span><span class="annot"><span class="annottext">Array
</span><a href="#local-6989586621679108830"><span class="hs-identifier hs-var">arr</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
</span><a href="Data.Text.Encoding.html#intToCSize"><span class="hs-identifier hs-var">intToCSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108829"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
</span><a href="Data.Text.Encoding.html#intToCSize"><span class="hs-identifier hs-var">intToCSize</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108828"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-469"></span><span>      </span><span id="local-6989586621679108820"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108820"><span class="hs-identifier hs-var">newDest</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word8) -&gt; IO (Ptr Word8)
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word8)
</span><a href="#local-6989586621679108823"><span class="hs-identifier hs-var">destPtr</span></a></span><span>
</span><span id="line-470"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679108819"><span class="annot"><span class="annottext">utf8len :: Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var hs-var">utf8len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108820"><span class="hs-identifier hs-var">newDest</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int
forall a b. Ptr a -&gt; Ptr b -&gt; Int
</span><a href="../../base/src/GHC.Ptr.html#minusPtr"><span class="hs-operator hs-var">`minusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108824"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-471"></span><span>      </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var">utf8len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108828"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. UnsafeShift a =&gt; a -&gt; Int -&gt; a
</span><a href="Data.Text.Internal.Unsafe.Shift.html#shiftR"><span class="hs-operator hs-var">`shiftR`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-472"></span><span>        </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; ByteString
</span><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-identifier hs-var">mkBS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108827"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var">utf8len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-473"></span><span>        </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-474"></span><span>          </span><span id="local-6989586621679108817"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108817"><span class="hs-identifier hs-var">fp'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="../../bytestring/src/Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">B.mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var">utf8len</span></a></span><span>
</span><span id="line-475"></span><span>          </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Data.Text.Internal.Functions.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108817"><span class="hs-identifier hs-var">fp'</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString)
-&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679108816"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108816"><span class="hs-identifier hs-var">ptr'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-476"></span><span>            </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="../../bytestring/src/Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">B.memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108816"><span class="hs-identifier hs-var">ptr'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679108824"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var">utf8len</span></a></span><span>
</span><span id="line-477"></span><span>            </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; ByteString
</span><a href="Data.Text.Internal.ByteStringCompat.html#mkBS"><span class="hs-identifier hs-var">mkBS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679108817"><span class="hs-identifier hs-var">fp'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679108819"><span class="hs-identifier hs-var">utf8len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-478"></span><span>
</span><span id="line-479"></span><span class="hs-comment">-- | Decode text from little endian UTF-16 encoding.</span><span>
</span><span id="line-480"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LEWith"><span class="hs-identifier hs-type">decodeUtf16LEWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-481"></span><span id="decodeUtf16LEWith"><span class="annot"><span class="annottext">decodeUtf16LEWith :: OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16LEWith"><span class="hs-identifier hs-var hs-var">decodeUtf16LEWith</span></a></span></span><span> </span><span id="local-6989586621679108814"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108814"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span id="local-6989586621679108813"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108813"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Char -&gt; Text
</span><a href="Data.Text.Internal.Fusion.html#unstream"><span class="hs-identifier hs-var">F.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Stream Char
</span><a href="Data.Text.Internal.Encoding.Fusion.html#streamUtf16LE"><span class="hs-identifier hs-var">E.streamUtf16LE</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108814"><span class="hs-identifier hs-var">onErr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108813"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-482"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LEWith"><span class="hs-pragma hs-type">decodeUtf16LEWith</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span class="hs-comment">-- | Decode text from little endian UTF-16 encoding.</span><span>
</span><span id="line-485"></span><span class="hs-comment">--</span><span>
</span><span id="line-486"></span><span class="hs-comment">-- If the input contains any invalid little endian UTF-16 data, an</span><span>
</span><span id="line-487"></span><span class="hs-comment">-- exception will be thrown.  For more control over the handling of</span><span>
</span><span id="line-488"></span><span class="hs-comment">-- invalid data, use 'decodeUtf16LEWith'.</span><span>
</span><span id="line-489"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LE"><span class="hs-identifier hs-type">decodeUtf16LE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-490"></span><span id="decodeUtf16LE"><span class="annot"><span class="annottext">decodeUtf16LE :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16LE"><span class="hs-identifier hs-var hs-var">decodeUtf16LE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16LEWith"><span class="hs-identifier hs-var">decodeUtf16LEWith</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-491"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16LE"><span class="hs-pragma hs-type">decodeUtf16LE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-492"></span><span>
</span><span id="line-493"></span><span class="hs-comment">-- | Decode text from big endian UTF-16 encoding.</span><span>
</span><span id="line-494"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BEWith"><span class="hs-identifier hs-type">decodeUtf16BEWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-495"></span><span id="decodeUtf16BEWith"><span class="annot"><span class="annottext">decodeUtf16BEWith :: OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16BEWith"><span class="hs-identifier hs-var hs-var">decodeUtf16BEWith</span></a></span></span><span> </span><span id="local-6989586621679108810"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108810"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span id="local-6989586621679108809"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108809"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Char -&gt; Text
</span><a href="Data.Text.Internal.Fusion.html#unstream"><span class="hs-identifier hs-var">F.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Stream Char
</span><a href="Data.Text.Internal.Encoding.Fusion.html#streamUtf16BE"><span class="hs-identifier hs-var">E.streamUtf16BE</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108810"><span class="hs-identifier hs-var">onErr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108809"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-496"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BEWith"><span class="hs-pragma hs-type">decodeUtf16BEWith</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-497"></span><span>
</span><span id="line-498"></span><span class="hs-comment">-- | Decode text from big endian UTF-16 encoding.</span><span>
</span><span id="line-499"></span><span class="hs-comment">--</span><span>
</span><span id="line-500"></span><span class="hs-comment">-- If the input contains any invalid big endian UTF-16 data, an</span><span>
</span><span id="line-501"></span><span class="hs-comment">-- exception will be thrown.  For more control over the handling of</span><span>
</span><span id="line-502"></span><span class="hs-comment">-- invalid data, use 'decodeUtf16BEWith'.</span><span>
</span><span id="line-503"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BE"><span class="hs-identifier hs-type">decodeUtf16BE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-504"></span><span id="decodeUtf16BE"><span class="annot"><span class="annottext">decodeUtf16BE :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16BE"><span class="hs-identifier hs-var hs-var">decodeUtf16BE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf16BEWith"><span class="hs-identifier hs-var">decodeUtf16BEWith</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-505"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf16BE"><span class="hs-pragma hs-type">decodeUtf16BE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-506"></span><span>
</span><span id="line-507"></span><span class="hs-comment">-- | Encode text using little endian UTF-16 encoding.</span><span>
</span><span id="line-508"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16LE"><span class="hs-identifier hs-type">encodeUtf16LE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-509"></span><span id="encodeUtf16LE"><span class="annot"><span class="annottext">encodeUtf16LE :: Text -&gt; ByteString
</span><a href="Data.Text.Encoding.html#encodeUtf16LE"><span class="hs-identifier hs-var hs-var">encodeUtf16LE</span></a></span></span><span> </span><span id="local-6989586621679108807"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108807"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Word8 -&gt; ByteString
</span><a href="Data.Text.Internal.Encoding.Fusion.html#unstream"><span class="hs-identifier hs-var">E.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Stream Char -&gt; Stream Word8
</span><a href="Data.Text.Internal.Encoding.Fusion.Common.html#restreamUtf16LE"><span class="hs-identifier hs-var">E.restreamUtf16LE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -&gt; Stream Char
</span><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier hs-var">F.stream</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108807"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-510"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16LE"><span class="hs-pragma hs-type">encodeUtf16LE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-511"></span><span>
</span><span id="line-512"></span><span class="hs-comment">-- | Encode text using big endian UTF-16 encoding.</span><span>
</span><span id="line-513"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16BE"><span class="hs-identifier hs-type">encodeUtf16BE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-514"></span><span id="encodeUtf16BE"><span class="annot"><span class="annottext">encodeUtf16BE :: Text -&gt; ByteString
</span><a href="Data.Text.Encoding.html#encodeUtf16BE"><span class="hs-identifier hs-var hs-var">encodeUtf16BE</span></a></span></span><span> </span><span id="local-6989586621679108804"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108804"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Word8 -&gt; ByteString
</span><a href="Data.Text.Internal.Encoding.Fusion.html#unstream"><span class="hs-identifier hs-var">E.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Stream Char -&gt; Stream Word8
</span><a href="Data.Text.Internal.Encoding.Fusion.Common.html#restreamUtf16BE"><span class="hs-identifier hs-var">E.restreamUtf16BE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -&gt; Stream Char
</span><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier hs-var">F.stream</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108804"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf16BE"><span class="hs-pragma hs-type">encodeUtf16BE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span class="hs-comment">-- | Decode text from little endian UTF-32 encoding.</span><span>
</span><span id="line-518"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LEWith"><span class="hs-identifier hs-type">decodeUtf32LEWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-519"></span><span id="decodeUtf32LEWith"><span class="annot"><span class="annottext">decodeUtf32LEWith :: OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32LEWith"><span class="hs-identifier hs-var hs-var">decodeUtf32LEWith</span></a></span></span><span> </span><span id="local-6989586621679108802"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108802"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span id="local-6989586621679108801"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108801"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Char -&gt; Text
</span><a href="Data.Text.Internal.Fusion.html#unstream"><span class="hs-identifier hs-var">F.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Stream Char
</span><a href="Data.Text.Internal.Encoding.Fusion.html#streamUtf32LE"><span class="hs-identifier hs-var">E.streamUtf32LE</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108802"><span class="hs-identifier hs-var">onErr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108801"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LEWith"><span class="hs-pragma hs-type">decodeUtf32LEWith</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-521"></span><span>
</span><span id="line-522"></span><span class="hs-comment">-- | Decode text from little endian UTF-32 encoding.</span><span>
</span><span id="line-523"></span><span class="hs-comment">--</span><span>
</span><span id="line-524"></span><span class="hs-comment">-- If the input contains any invalid little endian UTF-32 data, an</span><span>
</span><span id="line-525"></span><span class="hs-comment">-- exception will be thrown.  For more control over the handling of</span><span>
</span><span id="line-526"></span><span class="hs-comment">-- invalid data, use 'decodeUtf32LEWith'.</span><span>
</span><span id="line-527"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LE"><span class="hs-identifier hs-type">decodeUtf32LE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-528"></span><span id="decodeUtf32LE"><span class="annot"><span class="annottext">decodeUtf32LE :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32LE"><span class="hs-identifier hs-var hs-var">decodeUtf32LE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32LEWith"><span class="hs-identifier hs-var">decodeUtf32LEWith</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-529"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32LE"><span class="hs-pragma hs-type">decodeUtf32LE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span class="hs-comment">-- | Decode text from big endian UTF-32 encoding.</span><span>
</span><span id="line-532"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BEWith"><span class="hs-identifier hs-type">decodeUtf32BEWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Encoding.Error.html#OnDecodeError"><span class="hs-identifier hs-type">OnDecodeError</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-533"></span><span id="decodeUtf32BEWith"><span class="annot"><span class="annottext">decodeUtf32BEWith :: OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32BEWith"><span class="hs-identifier hs-var hs-var">decodeUtf32BEWith</span></a></span></span><span> </span><span id="local-6989586621679108799"><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108799"><span class="hs-identifier hs-var">onErr</span></a></span></span><span> </span><span id="local-6989586621679108798"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108798"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Char -&gt; Text
</span><a href="Data.Text.Internal.Fusion.html#unstream"><span class="hs-identifier hs-var">F.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Stream Char
</span><a href="Data.Text.Internal.Encoding.Fusion.html#streamUtf32BE"><span class="hs-identifier hs-var">E.streamUtf32BE</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="#local-6989586621679108799"><span class="hs-identifier hs-var">onErr</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679108798"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-534"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BEWith"><span class="hs-pragma hs-type">decodeUtf32BEWith</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-535"></span><span>
</span><span id="line-536"></span><span class="hs-comment">-- | Decode text from big endian UTF-32 encoding.</span><span>
</span><span id="line-537"></span><span class="hs-comment">--</span><span>
</span><span id="line-538"></span><span class="hs-comment">-- If the input contains any invalid big endian UTF-32 data, an</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- exception will be thrown.  For more control over the handling of</span><span>
</span><span id="line-540"></span><span class="hs-comment">-- invalid data, use 'decodeUtf32BEWith'.</span><span>
</span><span id="line-541"></span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BE"><span class="hs-identifier hs-type">decodeUtf32BE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span>
</span><span id="line-542"></span><span id="decodeUtf32BE"><span class="annot"><span class="annottext">decodeUtf32BE :: ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32BE"><span class="hs-identifier hs-var hs-var">decodeUtf32BE</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OnDecodeError -&gt; ByteString -&gt; Text
</span><a href="Data.Text.Encoding.html#decodeUtf32BEWith"><span class="hs-identifier hs-var">decodeUtf32BEWith</span></a></span><span> </span><span class="annot"><span class="annottext">OnDecodeError
</span><a href="Data.Text.Encoding.Error.html#strictDecode"><span class="hs-identifier hs-var">strictDecode</span></a></span><span>
</span><span id="line-543"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#decodeUtf32BE"><span class="hs-pragma hs-type">decodeUtf32BE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-544"></span><span>
</span><span id="line-545"></span><span class="hs-comment">-- | Encode text using little endian UTF-32 encoding.</span><span>
</span><span id="line-546"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32LE"><span class="hs-identifier hs-type">encodeUtf32LE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-547"></span><span id="encodeUtf32LE"><span class="annot"><span class="annottext">encodeUtf32LE :: Text -&gt; ByteString
</span><a href="Data.Text.Encoding.html#encodeUtf32LE"><span class="hs-identifier hs-var hs-var">encodeUtf32LE</span></a></span></span><span> </span><span id="local-6989586621679108796"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108796"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Word8 -&gt; ByteString
</span><a href="Data.Text.Internal.Encoding.Fusion.html#unstream"><span class="hs-identifier hs-var">E.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Stream Char -&gt; Stream Word8
</span><a href="Data.Text.Internal.Encoding.Fusion.Common.html#restreamUtf32LE"><span class="hs-identifier hs-var">E.restreamUtf32LE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -&gt; Stream Char
</span><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier hs-var">F.stream</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108796"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32LE"><span class="hs-pragma hs-type">encodeUtf32LE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-549"></span><span>
</span><span id="line-550"></span><span class="hs-comment">-- | Encode text using big endian UTF-32 encoding.</span><span>
</span><span id="line-551"></span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32BE"><span class="hs-identifier hs-type">encodeUtf32BE</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.html#Text"><span class="hs-identifier hs-type">Text</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../bytestring/src/Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-552"></span><span id="encodeUtf32BE"><span class="annot"><span class="annottext">encodeUtf32BE :: Text -&gt; ByteString
</span><a href="Data.Text.Encoding.html#encodeUtf32BE"><span class="hs-identifier hs-var hs-var">encodeUtf32BE</span></a></span></span><span> </span><span id="local-6989586621679108794"><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108794"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Stream Word8 -&gt; ByteString
</span><a href="Data.Text.Internal.Encoding.Fusion.html#unstream"><span class="hs-identifier hs-var">E.unstream</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Stream Char -&gt; Stream Word8
</span><a href="Data.Text.Internal.Encoding.Fusion.Common.html#restreamUtf32BE"><span class="hs-identifier hs-var">E.restreamUtf32BE</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -&gt; Stream Char
</span><a href="Data.Text.Internal.Fusion.html#stream"><span class="hs-identifier hs-var">F.stream</span></a></span><span> </span><span class="annot"><span class="annottext">Text
</span><a href="#local-6989586621679108794"><span class="hs-identifier hs-var">txt</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-553"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#encodeUtf32BE"><span class="hs-pragma hs-type">encodeUtf32BE</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span class="annot"><a href="Data.Text.Encoding.html#cSizeToInt"><span class="hs-identifier hs-type">cSizeToInt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-556"></span><span id="cSizeToInt"><span class="annot"><span class="annottext">cSizeToInt :: CSize -&gt; Int
</span><a href="Data.Text.Encoding.html#cSizeToInt"><span class="hs-identifier hs-var hs-var">cSizeToInt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CSize -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-557"></span><span>
</span><span id="line-558"></span><span class="annot"><a href="Data.Text.Encoding.html#intToCSize"><span class="hs-identifier hs-type">intToCSize</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span>
</span><span id="line-559"></span><span id="intToCSize"><span class="annot"><span class="annottext">intToCSize :: Int -&gt; CSize
</span><a href="Data.Text.Encoding.html#intToCSize"><span class="hs-identifier hs-var hs-var">intToCSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-560"></span><span>
</span><span id="line-561"></span><span class="annot"><a href="Data.Text.Encoding.html#word16ToWord8"><span class="hs-identifier hs-type">word16ToWord8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word16"><span class="hs-identifier hs-type">Word16</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-562"></span><span id="word16ToWord8"><span class="annot"><span class="annottext">word16ToWord8 :: Word16 -&gt; Word8
</span><a href="Data.Text.Encoding.html#word16ToWord8"><span class="hs-identifier hs-var hs-var">word16ToWord8</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word16 -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span id="local-6989586621679109481"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;_hs_text_decode_utf8&quot;</span></span><span> </span><span id="c_decode_utf8"><span class="annot"><a href="Data.Text.Encoding.html#c_decode_utf8"><span class="hs-identifier hs-var">c_decode_utf8</span></a></span></span><span>
</span><span id="line-565"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#MutableByteArray%23"><span class="hs-identifier hs-type">MutableByteArray#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679109481"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span>
</span><span id="line-566"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-567"></span><span>
</span><span id="line-568"></span><span id="local-6989586621679109451"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;_hs_text_decode_utf8_state&quot;</span></span><span> </span><span id="c_decode_utf8_with_state"><span class="annot"><a href="Data.Text.Encoding.html#c_decode_utf8_with_state"><span class="hs-identifier hs-var">c_decode_utf8_with_state</span></a></span></span><span>
</span><span id="line-569"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#MutableByteArray%23"><span class="hs-identifier hs-type">MutableByteArray#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679109451"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span>
</span><span id="line-570"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-571"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#CodePoint"><span class="hs-identifier hs-type">CodePoint</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="Data.Text.Encoding.html#DecoderState"><span class="hs-identifier hs-type">DecoderState</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-572"></span><span>
</span><span id="line-573"></span><span id="local-6989586621679109493"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;_hs_text_decode_latin1&quot;</span></span><span> </span><span id="c_decode_latin1"><span class="annot"><a href="Data.Text.Encoding.html#c_decode_latin1"><span class="hs-identifier hs-var">c_decode_latin1</span></a></span></span><span>
</span><span id="line-574"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#MutableByteArray%23"><span class="hs-identifier hs-type">MutableByteArray#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679109493"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span></span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;_hs_text_encode_utf8&quot;</span></span><span> </span><span id="c_encode_utf8"><span class="annot"><a href="Data.Text.Encoding.html#c_encode_utf8"><span class="hs-identifier hs-var">c_encode_utf8</span></a></span></span><span>
</span><span id="line-577"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#ByteArray%23"><span class="hs-identifier hs-type">ByteArray#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-578"></span></pre></body></html>